我正在使用MEF将插件加载到我的宿主应用程序。主机和插件都是.Net 4.0 Client Profile。但是,其中一些插件引用了一个库System.Data.SQLite.dll,它需要一个带有以下内容的App.config文件:
<?xml version="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
</configuration>
过去我会将[libname] .dll.config文件放在与[libname] .dll相同的目录中,它会起作用。但是,我的插件库位于不同的文件夹中,并且将应用程序配置文件和System.Data.SQLite.dll复制到该文件夹不起作用。我的解决方案正确编译,但是当插件尝试实例化数据库时,我在运行时遇到以下异常:
无法加载文件或程序集'System.Data.SQLite,Version = 1.0.65.0,Culture = neutral,PublicKeyToken = db937bc2d44ff139'或其依赖项之一。系统找不到指定的文件。
我认为这不重要,但它发生在这一行(EventDbWriter属于数据库包装类):
EventDbWriter = EventDbWriter.CreateWriter(filename, systemId, applicationId, applicationStatus, projectPath)
非常感谢任何帮助。
编辑:一些值得注意的fuslogvw行如下:
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\...\VS2010\DL_PEM\branches\DL_PEM\DL_PEM\bin\Debug\DL_PEM.vshost.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = DemoModule, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, processorArchitecture=x86
(Fully-specified)
LOG: Appbase = file:///C:/...\VS2010/DL_PEM/branches/DL_PEM/DL_PEM/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = DL_PEM.vshost.exe
Calling assembly : System.ComponentModel.Composition, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\...\VS2010\DL_PEM\branches\DL_PEM\DL_PEM\bin\Debug\DL_PEM.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: Attempting download of new URL file:///C:/.../VS2010/DL_PEM/branches/DL_PEM/DL_PEM/bin/Debug/DemoModule.DLL.
LOG: Attempting download of new URL file:///C:/.../VS2010/DL_PEM/branches/DL_PEM/DL_PEM/bin/Debug/DemoModule/DemoModule.DLL.
LOG: Attempting download of new URL file:///C:/.../VS2010/DL_PEM/branches/DL_PEM/DL_PEM/bin/Debug/DemoModule.EXE.
LOG: Attempting download of new URL file:///C:/.../VS2010/DL_PEM/branches/DL_PEM/DL_PEM/bin/Debug/DemoModule/DemoModule.EXE.
LOG: All probing URLs attempted and failed.
检测到另一个程序集绑定错误,部分日志如下:
LOG: Using application configuration file: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\11.0.0\IntelliTrace.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: GAC Lookup was unsuccessful.