I'm trying to load an assembly at runtime. For that I'm using the following line:
file is a FileInfo object, so file.FullName returns the full path to the file on the filesystem, e.g.: c:\mywebsite\dlls\myassembly.dll
When I try to execute the line above I get the following error:
Could not load file or assembly 'c:\mywebsite\dlls\myassembly.dll' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
I'm sure this isn't a dependency problem, and I don't know what's an "invalid codebase"
Note that if I put the assembly directly on the BIN folder of the site everything works correctly, I just can't make load dynamically.
To supplement Schroedingers Cat's answer, you might want to look at Assembly.LoadFile if you only have the file path. But you might get security issues when running from ASP.NET which may require configuring permissions on the file system, to allow your website to access the file.
See here for more info: How to call a Managed DLL File in C#?
User contributions licensed under CC BY-SA 3.0