app.config dependentAssembly不工作

Jas*_*son 8 c# app-config

我想直接链接到编译/运行时使用的Dll.我的程序布局是这样的:Console Exe启动一个winform dll.该DLL使用一堆dll来执行.Appconfig位于winform dll的项目中.基于一些阅读,winform dll是否正在寻找错误的app.config?我打算使用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>
Run Code Online (Sandbox Code Playgroud)

位置绝对正确.dll没有强名称,因此publicKeyToken ="null".我的所有版本都是1.0.0.0.当我查看我引用的dll的属性时,文化是空白的.我也应该这样吗?有什么看起来我做错了吗?

Ada*_*Tal 4

App.config 不应在 dll 上使用,而只能与可执行文件一起使用。

如果您在可执行文件中加载 dll,则该 dll 将使用正在运行的可执行文件的配置文件,并忽略为其定义的配置。

如果您希望可以使用一些丑陋的代码读取配置的键,这些代码从当前程序集的配置文件中获取它们。

您应该做的是将相关配置放入 exe 配置文件中。

更新

在以下问题中找到了更多信息:C# DLL config file