How to load a remote assembly using Assembly.Load
1 min read
If you try to load a remote assembly using it’s path you’ll likely get a permission or operation exception.
When using LoadFrom:
Assembly a1 = Assembly.LoadFrom(file);
```python
I got this error. Could not load file or assembly or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

I figured I could copy it locally, but knew there must be a better way. So I scoured the interwebs and found this post on StackOverflow:
[https://stackoverflow.com/questions/8308312/assembly-loaded-using-assembly-loadfrom-on-remote-machine-causes-securityexcep](https://stackoverflow.com/questions/8308312/assembly-loaded-using-assembly-loadfrom-on-remote-machine-causes-securityexcep)
Which basically tells us to use Assembly.Load instead of Assembly.LoadFrom. Here’s the code that works:
```csharp
Assembly a2 = Assembly.Load(File.ReadAllBytes(file));Jon
Share: