mercredi 9 juin 2021

FileNotFoundException when loading assembly

I'm getting a FileNotFoundException when i'm trying to access the ExportedTypes of a loaded assembly.

Basically, I have a solution with two projects: Proj1 and Proj2. Proj1 has a reference from Proj2 and i'm trying to load a DLL of Proj1 through their path. This was the code I tryed:

Dim sLoad As System.Reflection.Assembly
Try
   sLoad = System.Reflection.Assembly.LoadFrom(PathDLL)
   Dim ob = sLoad.ExportedTypes
Catch ex As System.IO.FileNotFoundException
   Dim msh = ex.Message
End Try

I already checked AppDomain.CurrentDomain.GetAssemblies() and has the assemblie to my Proj2 so I don't understand why it doesn't work. Already tryed LoadFile too.

This is my error message:

Could not load file or assembly 'Proj2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

This is my Fusion Log:

=== Pre-bind state information ===
LOG: DisplayName = Proj2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Users/jsantos/Source/Workspaces/UP/UP/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\jsantos\Source\Workspaces\UP\UP\bin\Debug\UP.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.




Aucun commentaire:

Enregistrer un commentaire