We have a .Net application that successfully "load" .dll libraries from a specific folder in Windows Operative System. The .Net framework we have been using so far is 4.6. All the .dll libraries that the application loads were compiled in x86. The following code is an excerpt of how we are loading the libraries and getting their types:
1. try{
2. AssemblyFileDescriptor assemblyFile = new AssemblyFileDescriptor(assemblyPath);
3. var assm = Assembly.LoadFrom(assemblyPath);
4. var types = assm.GetExportedTypes();
5. ...
6. }catch (Exception e) {
7. ...}
The libraries in a specific folder, let's say
C:\Program Files (x86)\FOLDER
, are loading to the variable assm without any exception. The problem occurs when we migrated our .Net "stand alone" application to a website application with a Web.config file. In the website application, the load function fails when getting the types. Then the 4th line throws the exception. We have been using the ISS Express.
We have already tried:
- Using a different Load function such as "UnsafeLoadFrom".
- Re-compiling all the .dll libraries in x86 and x64.
- Setting up different configurations for the Web.Config file such as including
<trust level="Full" />
or<loadFromRemoteSources enabled="true" />
. - Debugging the loading function of each library. Some of them can load successfully, but there are others that throw a Loading Exception.
- Setting in the ISS Express "True" the variable "Enable 32-bit applications".
The specific error states "System.Reflection.ReflectionTypeLoadException":
Any idea of how tackling this issue? Let me know if you need further information.