0

I load a project from TFS to my local machine. But it need log4Net libary, and I download it from internet. It is rebuilt successfully. But when it runs, the exception comes.

Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, 
PublicKeyToken=1b44e1d426115821' or one of its dependencies. 
The located assembly's manifest definition does not match the assembly reference. 
(Exception from HRESULT: 0x80131040)

I know this is the problem of mixing the version and publickey token. But my question is, when the code runs in visual studio, how can it know that it need log4net in version1.2 ? Anyone can help? Thank you.

Sun Robin
  • 583
  • 4
  • 13

1 Answers1

0

What you have here is an assembly in your project that is referencing the log4net assembly with this version; it can be a direct reference, or an indirect reference (your project references A.dll that references log4net.dll)

Look through your projects to find the referencing assembly, and either satisfy the reference (get the correct version through nuget, that's the easiest) or change it. The referenced assemblies are contained in the project file (*.csproj or whatever extension is applicable to your language) with a Reference tag

When you include a reference, the naming strength will depend on what settings you chose:

<Reference Include="name">
<!-- here no version is specified because no specific version is needed -->

<Reference Include="name, Version=xxx, Culture=neutral, processorArchitecture=MSIL">     
<-- version is specified, perhaps because a specific version was referenced at one time --> 

Some more info can be found on this very site

Community
  • 1
  • 1
samy
  • 14,832
  • 2
  • 54
  • 82
  • Thank you for your response. But how does A.dll know that it need log4net of this specific version? I assume that some version binding information must be stored somewhere. Have I missed something? – Sun Robin Oct 20 '14 at 11:30