3

My question is closely related to the one

Log4Net : 2 libraries need 2 different version of it

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. 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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Srivathsan M
  • 87
  • 1
  • 9
  • 2
    And the roadblock is...? – D'Arcy Rittich Oct 09 '12 at 14:33
  • @RedFilter - the log4net assemblies have the same file name, and if you copy one the other can no longer be found - the exception is thrown that assembly (with full assembly name) cannot be loaded. – veljkoz Oct 09 '12 at 14:44
  • Sorry for not elaborating the "roadblock" earlier. To add on, I even tried renaming the original "log4net.dll"s as "log4net_dotNet2.dll" and "log4net_dotNet4.dll". But the CLR seems to be expecting only log4net.dll. Maybe, I am missing some fundamental understanding of .Net here. I am yet to look into the the [link](http://msdn.microsoft.com/en-us/library/7wd6ex19.aspx) provided in the answer by "veljkoz" down below – Srivathsan M Oct 10 '12 at 05:21

3 Answers3

2

First off, you can't have all of the dll's in the same folder (as you already found).

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>
veljkoz
  • 8,384
  • 8
  • 55
  • 91
  • I like the Assembly.LoadFrom solution. Anyway you should also be able to register both of them in GAC. – Felix K. Oct 10 '12 at 08:16
0

I think it's safe just use the version targeting .net 2.0.

xing
  • 447
  • 2
  • 6
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

Link : http://msdn.microsoft.com/en-us/library/w4atty68(v=vs.71).aspx

Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51