In our application (solution with 65 projects), all referenced assemblies are analysed in run-time for the presence of Ninject modules (there is some filtering applied too). The modules are loaded later into the Ninject kernel and each module declares bindings for the kernel.
We have adopted a loader that loads the referenced assemblies into a separate assembly in reflection only mode. The difference from the way Ninject can load assemblies from the directory is that the directory can contain assemblies with modules that should not be loaded. And also at the very start, not all referenced assemblies are loaded.
The problem is that the loader (credit to Sacha Barber) cannot load some assemblies with the
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information
and the LoaderExceptions
with one entry:
Method 'BeforeLoad' in type 'Lekis.AppBase.Core.BLLBaseCore' from assembly 'AppBaseCore, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation.
Here are some "fun" facts:
- method
BeforeLoad
is virtual and an implementation of an interface method - last week the loader exception was saying different method did not have an implementation (that method was not virtual) and later, when I have explicitly implemented it, the message said the method was not found.
- last week the target framework for assembly
AppBaseCore
was .NET 3.5 and 3 assemblies failed to load - now the target framework for assembly
AppBaseCore
is .NET 4 and 5 assemblies failed to load - everything is fine with the application otherwise
There is nothing wrong (obviously) with the assemblies when I checked them with ILSpy and ILDAsm.
At this point, I am really lost and don't know how to approach this issue.
Any help is appreciated.
Thanks
BeforeLoad
is virtual and an implementation of an interface method". is it really, though? Check all the answers here to make sure you're not hitting a versioning/loading conflict of some sort. ILSpy/ILDAsm aren't going to report any problems since the assembly is structurally valid. – Downcomer