开发者

Retrieving DLL information in .NET

My problem:

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

My Code:

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:

Could not load file or assembly 'file', Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependenci开发者_开发百科es.The system cannot find the file specified.

If that line were to work, I figure I would simply go:

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

and then unload the Application Domain.


The issue here may be related to the SetupInformation for the new AppDomain. When you create your new AppDomain, try creating it like this, so it inherits the same security and setup info as the existing AppDomain:

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜