我在读取文件夹中的dll和进程类型。GetTypes方法无法加载文件或程序集错误
xxx.dll
xxx.interfaces.dll
当我加载上装配xxx.dll和呼叫GetTypes,它抛出一个异常...
{System.IO.FileNotFoundException: Could not load file or assembly 'xxx.Interfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'xxx.Interfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
=== Pre-bind state information ===
LOG: User = xxx
LOG: DisplayName = xxx.Interfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///<myapp>/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: <myapp>\bin\Debug\Diagrammer.vshost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\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.
}
好像它试图获取从启动应用程序的路径依赖的DLL比装载的组件还要多。当我检查加载和处理程序集xxx.Interfaces.dll时,它工作正常。
您是否尝试过所有的'Assembly.Load'和'Assembly.LoadFrom'? –
我正在使用LoadFile api。感谢您的参考,LoadFrom正在工作。 –
你应该给它作为答案。对于处于我的情况的其他人可能会有所帮助。我会尽力在我的观察之上。 –