Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 加载DLL时动态加载app.config_C#_Dll - Fatal编程技术网

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..."