app.config dependentAssembly not working
本文关键字:working not dependentAssembly config app | 更新日期: 2023-09-27 18:03:35
我想直接链接到编译/运行时使用的dll。我的程序布局如下:Console Exe启动一个winform dll。该dll使用一堆dll来执行。Appconfig位于winform dll的项目中。基于一些阅读,是winform dll寻找错误的应用程序配置?我打算使用Assembly.LoadFrom();
执行我的dll我创建了一个app.config文件,并在 部分中添加了以下几行<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="CommonConversions"
publicKeyToken="null"
culture="neutral" />
<codeBase version="1.0.0.0"
href="file://C://BMS_ACTD//bin//DX//Globals//CommonConversions.dll"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="GlobalConstants"
publicKeyToken="null"
culture="neutral" />
<codeBase version="1.0.0.0"
href="file://C://BMS_ACTD//bin//DX//Globals//GlobalConstants.dll"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="MessageInstance"
publicKeyToken="null"
culture="neutral" />
<codeBase version="1.0.0.0"
href="file://C://BMS_ACTD//bin//DX//Globals//MessageInstance.dll"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="MessageInterface"
publicKeyToken="null"
culture="neutral" />
<codeBase version="1.0.0.0"
href="file://C://BMS_ACTD//bin//DX//Globals//MessageInterface.dll"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="ToolsInterface"
publicKeyToken="null"
culture="neutral" />
<codeBase version="1.0.0.0"
href="file://C://BMS_ACTD//bin//DX//Globals//ToolsInterface.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
位置绝对正确。dll不是强命名的,因此publicKeyToken="null"。我所有的版本都是1.0.0.0。当我查看我引用的dll的属性时,文化是空白的。我的也应该这样吗?有什么看起来我做错了吗?
App。Config不能用于DLL,只能用于可执行文件。
如果在可执行文件中加载dll, dll将使用正在运行的可执行文件的配置文件,并且将忽略为他定义的配置。
如果你愿意,你可以使用一些丑陋的代码从当前程序集的配置文件中读取配置的键。
你应该做的是把相关的配置放在exe配置文件中。
c# DLL配置文件