Mysql: The located assembly's manifest definition does not match the assembly reference

来源:互联网 发布:淘宝用vr试穿 编辑:程序博客网 时间:2024/06/05 11:05

 

将mysql.data.dll 从版本6.9.4.0换成6.5.4.0是遇到以下异常:

 

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

 

原因:

编译目录(debug或release)下的dll版本和.csproj中定义的版本不一致。

 

解决办法: 将debug或release下的dll版本换成与.csproj中定义的版本一致。

找到版本不一致的原因:比如多个.csproj引用了的相同的dll但是版本不一致。最后发现我有三个proj引用了MySql.Data但是版本不同,所以每次编译后就会有个csproj中的dll版本与实际copy的版本不一样。

 

更好的解决办法:

用GAC管理dll.

http://www.cnblogs.com/chenlulouis/archive/2010/06/30/1768176.html

http://stackoverflow.com/questions/215026/the-located-assemblys-manifest-definition-does-not-match-the-assembly-reference

https://msdn.microsoft.com/en-us/library/ex0ss12c%28VS.80%29.aspx  (GAC命令的用法)

我的电脑在目录C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools 下可以找到GACUtil.exe

 

 

 

 

 

阅读全文
0 0
原创粉丝点击