Saturday, May 20, 2017

Assembly.LoadFrom does not load types within a DLL

Problem
I'm using Assembly.LoadFrom to load an assembly during runtime and it's not able to load all of the types.

A useful symptom is that RequestingAssembly (in Resolve event) is null.

Solution
DLL names cannot match the containing folder.

For example, if I am trying to load ../Project/MyDLL/MyDLL.dll, it'll fail, simply because "MyDLL" is both the DLL name and folder name. The solution is therefore to put MyDLL.dll in a differently named folder.

Yes, this makes no sense, but I am not concerned about the internal workings of Assembly.LoadFrom(). After many hours of being confused, I finally found the solution here: http://stackoverflow.com/a/10245012/1538717 . I face-palmed so hard!

No comments:

Post a Comment

There was an error in this gadget