简体   繁体   English

如何在同一解决方案中使用2个不同的log4net程序集 - 每个程序集针对不同版本的.Net Framework?

[英]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: 使用这些知识,您可以:

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.

相关问题 引用不同版本的log4net - Referencing different versions of log4net 在解决方案中在不同层中使用log4net的最佳方法是什么 - What is the best approach to use log4net in different layers with in a solution 如何在不同层中使用unity log4net扩展 - How to use unity log4net extenstion in different layers 如何设置log4net每天将文件记录到不同的文件夹中? - How I can set log4net to log my files into different folders each day? 无法将Log4Net与.net Framework 4一起使用 - Unable to use Log4Net with .net Framework 4 如何使用具有不同log4net版本要求的两个不同NuGet包 - How to use two different NuGet packages with different log4net version requirements log4net:在哪里放置静态 LogManger 对象? (在解决方案的不同项目中使用它,每个项目都有一个单独的配置文件) - log4net: Where to place static LogManger object? (using it in different projects of a solution, each having an individual config-file) 使用log4net记录多个程序集 - log multiple assemblies using log4net 如何将StructureMap与同一接口的2个不同对象(log4net记录器)连接 - How can I wire StructureMap with 2 different objects (log4net loggers) of the same interface 将log4net追加程序添加到具有不同bufferSize的数据库 - log4net appenders to database with different bufferSize
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM