C# 加载DLL时动态加载app.config
我的C# 加载DLL时动态加载app.config,c#,dll,C#,Dll,我的DLL正在由另一个exe加载。DLL使用托管在Nuget上的库,例如Autofac、Autofac.WebApi2。 我的app.config看起来像这样 <?xml version="1.0" encoding="utf-8"?> <configuration> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <depend
DLL
正在由另一个exe加载。DLL
使用托管在Nuget
上的库,例如Autofac、Autofac.WebApi2。
我的app.config看起来像这样
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
app.config也部署到与名为
{mydll.dll.config}
的exe
相同的目录中。如何动态加载此配置以使其利用程序集绑定?DLL文件的app.config
充其量只是提示您应该在EXEs app.config(或web.config)中放置什么。它没有被使用。一些VS工具将为DLL创建app.config文件的事实只是残酷笑话的一部分。我可以手动添加一个exe.config吗?然后从dll加载exe.config?dll文件的app.config
充其量只是提示您应该在EXEs app.config(或web.config)中放置什么。它没有被使用。一些VS工具将为DLL创建app.config文件的事实只是残酷笑话的一部分。我可以手动添加一个exe.config吗?然后从dll加载exe.config?
"Could not load file or assembly 'System.Web.Http, Version=5.2.0.0, Culture=neutral, PublicKeyToken={token}' or one of its dependencies..."