Retrieving DLL information in .NET.

My problem:

Given the list of DLL paths, find their version number and any links collected. Some may point to the same DLL, but with a different path or version.

My code is:

Dim otherDomain As AppDomain = AppDomain.CreateDomain("otherDomain") otherDomain.DoCallBack(Sub() Assembly.ReflectionOnlyLoadFrom("filePath") End Sub) Dim assemblies As New List(Of Assembly)(otherDomain.ReflectionOnlyGetAssemblies()) 

The last line throws:

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

If this line worked, I suppose I just go:

 assemblies(0).GetName.version.tostring assemblies(0).GetReferencedAssemblies 

and then unload the Application Domain .

+4
source share
1 answer

The problem here may be related to SetupInformation for the new AppDomain. When you create your new AppDomain, try creating it so that it inherits the same security and configuration information as the existing AppDomain:

 AppDomain.CreateDomain("otherDomain", AppDomain.CurrentDomain.Evidence, AppDomain.CurrentDomain.SetupInformation); 

The assembly search location for the new AppDomain will now match the original AppDomain, and your assembly should be found.

+1
source

Source: https://habr.com/ru/post/1347312/


All Articles