简体   繁体   中英

DLL version mismatch issue

* Introduction to the Issue

I am using a software that uses the.Net framework to perform some tasks.

We are trying to use the Mailkit.dll file but when using it we are faced with the message:

Internal: Could not execute code stage because exception thrown by code stage: Could not load file or assembly 'System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

and from what I have concluded so far the Mailkit.dll depends on Mimekit.dll that depends on System.memory.dll, something like that.

Mailkit.dll > Mimekit.dll > System.Memory.dll

Version details:

  • .Net framework installed on machine: 4.7.3190
  • .Net framework used by application: 4.7
  • Mailkit.dll version: 3.4.1
  • Mimekit.dll Version: 3.4.1
  • System.Memory.dll in application folder Version:4.6.28619.01

I don't Know what's the issue or why this is happening but I am pretty sure it has to do with version issue so any help is welcomed.

The version numbers you provided are a good starting point.

For .NETFramework 4.7, MailKit v3.4.1 depends on MimeKit v3.4.1 which depends on System.Memory >= v4.5.5.

System.Memory with NuGet version v4.5.5 has an AssemblyFileVersion of 4.6.31308.01 (the number that shows in windows explorer) but an AssemblyVersion of 4.0.1.2 . The assembly number is what really matters when the CLR looks for assemblies. The CLR looks for v4.0.1.2 when loading MimeKit but can only find v4.0.1.1 .

The version that ends up in your output is older than the version required. I found that the version that is actually in your output is from System.Memory v4.5.4. AssemblyFileVersion : 4.6.28619.01 . AssemblyVersion : 4.0.1.1 .

This is probably happening if you are referencing System.Memory nuget package directly. If you do have a direct package reference to System.Memory, then you need to upgrade it.

If you were using SDK styled projects, you would get an error preventing this from happening. But you should still be getting a build warning about version conflicts detected. 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM