C# 程序兼容同一个dll的不同版本

当程序多个dll引用同一个dll的不同版本时,程序启动会报错,此时需要在启动程序集的App.config下增加以下配置

<dependentAssembly>
				<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
				<bindingRedirect oldVersion="0.0.0.0-2.0.8.0" newVersion="2.0.8.0" />
			</dependentAssembly>

示例:

<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
	<runtime>
		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
			<dependentAssembly>
				<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
				<bindingRedirect oldVersion="0.0.0.0-2.0.8.0" newVersion="2.0.8.0" />
			</dependentAssembly>
		</assemblyBinding>
	</runtime>
</configuration>

你可能感兴趣的:(c#,开发语言)