2010-12-08 30 views
0

我有一個包含多個可執行文件的文件夾。目前,每個executable.exe.config文件都配置了程序集綁定重定向。有沒有一種方法可以只配置一次,並且該文件夾中的所有可執行文件都會自動將其選中?我想避免machine.config,因爲這將適用於整個計算機。爲多個可執行文件配置assemblyBinding一次

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
    <publisherPolicy apply="yes" /> 
    <dependentAssembly> 
    <assemblyIdentity name="SomeAssembly" publicKeyToken="10addddbec4aebba" /> 
    <publisherPolicy apply="yes" /> 
     <bindingRedirect oldVersion="0.0.0.0-7.9.999.0" newVersion="5.8.11.5" /> 
    </dependentAssembly> 
    <dependentAssembly> 
    <assemblyIdentity name="SomeOtherAssembly" publicKeyToken="23adeddbac4ae12a" /> 
    <publisherPolicy apply="yes" /> 
     <bindingRedirect oldVersion="0.0.0.0-7.9.999.0" newVersion="5.8.11.5" /> 
    </dependentAssembly> 
</assemblyBinding> 

回答

1

可以在不同部分「分割」你的配置並將這些部分放到外部文件中。你會爲每個exe文件清空配置文件,並在其中添加這樣一個部分。但Enterprise Lib爲此提供了一個應用程序塊。
另一種解決方案是使用符號文件鏈接 - 又名junction - 將每個配置重定向到全局配置(但我不建議這樣做)。

0

我相信沒有辦法爲多個可執行文件創建一個配置文件。 MSDN只提及兩個選項 - executable.exe.config和全球machine.config

是來到我心中唯一的解決方案是創建一個大的可執行文件,具有目前所有的可執行文件的功能(和一個常用的配置),然後讓你的當前可執行文件運行大單以某種開關等

相關問題