[英]How to use 2 different log4net assemblies - each targeted for different versions of the .Net Framework, in the same solution?
My question is closely related to the one 我的问题与那个问题密切相关
Log4Net : 2 libraries need 2 different version of it Log4Net:2个库需要2个不同的版本
but slightly different. 但略有不同。
While our Main EXE is compiled with .Net Framework 4.0, some of the referenced assemblies are compiled for Framework v2.0 and we have to add logging within those assemblies as well. 虽然我们的主EXE是使用.Net Framework 4.0编译的,但是一些引用的程序集是为Framework v2.0编译的,我们也必须在这些程序集中添加日志记录。 While we had chosen log4net v1.2.11 (the latest, I believe), we are hitting a road-block in using the 2 different assembles in our solution. 虽然我们选择了log4net v1.2.11(最新的,我相信),但我们在使用解决方案中的2个不同组件时遇到了障碍。
First off, you can't have all of the dll's in the same folder (as you already found). 首先,您不能将所有dll放在同一个文件夹中(如您所见)。
Here it's explained how the runtime tries to load the assembly. 这里解释了运行时如何尝试加载程序集。
Using this knowledge, you could: 使用这些知识,您可以:
Redirect assembly versions (if they are compatible, which I think they are) - eg from old log4net dll to the new dll 重定向程序集版本 (如果它们是兼容的,我认为它们是这样的) - 例如从旧的log4net dll到新的dll
Specify assemlby location that should be used when loading assemblies (eg put it in \\Libs folder, and reference that) 指定加载程序集时应使用的assemlby位置 (例如,将其放在\\ Libs文件夹中,并引用它)
Load the assembly manually - theoretically, this could work because it's loading that assembly into the domain. 手动加载程序集 - 理论上,这可能有效,因为它将该程序集加载到域中。
One example, taken from here ("Multiple Assemblies with the Same Name"): 一个例子,取自这里 (“具有相同名称的多个装配”):
<dependentAssembly>
<assemblyIdentity name="Server" publicKeyToken="c0305c36380ba429" />
<codeBase version="1.0.0.0" href="v1/Server.dll"/>
<codeBase version="2.0.0.0" href="v2/Server.dll"/>
</dependentAssembly>
我认为只使用针对.net 2.0的版本是安全的。
You can use this section 您可以使用此部分
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="2.0" />
</startup>
</configuration>
Link : http://msdn.microsoft.com/fr-fr/library/vstudio/bbx34a2h.aspx 链接: http : //msdn.microsoft.com/fr-fr/library/vstudio/bbx34a2h.aspx
Link : http://msdn.microsoft.com/en-us/library/w4atty68(v=vs.71).aspx 链接: http : //msdn.microsoft.com/en-us/library/w4atty68(v = vs.71).aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.