首页 文章

如何找到引用程序集的错误版本的内容并修复它?

提问于
浏览
3

同事们,

我在开发环境中遇到了问题 . 我创建了一个使用EntityFramework和ASP.NET Identity的项目,然后是一些其他项目,如WCF服务和WebForms站点引用第一个 . 项目编译并正常工作,但当我尝试在Package Manager Console中使用“Update-Database”来更新启用迁移的数据库时,我得到:

System.Data.Entity.Core.MetadataException:指定的架构无效 . 错误:(0,0):错误0004:无法加载文件或程序集'Microsoft.AspNet.Identity.EntityFramework,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一 . 定位的程序集的清单定义与程序集引用不匹配 . (HRESULT异常:0x80131040)

我在每个项目中引用的Microsoft.AspNet.Identity.EntityFramework版本是2.0.0.0(我在某些时候用NuGet升级了它) . 如何找出谁正在寻找旧版本并解决该问题?

我尝试了以下步骤:

  • 手动检查Visual Studio中每个项目的引用 . 所有这些都有正确的版本(2.0.0.0)和指定的DLL路径,“特定版本”属性设置为“False” .

  • 清除AppData和C:\ Windows中的“临时ASP.NET文件”...

  • 当然清除了整个解决方案(删除了bin&obj文件夹)

  • 手动检查每个* .csproj文件是否存在无效引用

  • 使用NuGet重新安装软件包(Update-Package -includePrerelease -reinstall)

  • 在每个App.config / Web.config中包含程序集绑定重定向:

<runtime>

<assemblyBinding> <dependentAssembly> <assemblyIdentity name =“Microsoft.AspNet.Identity.EntityFramework”publicKeyToken =“31bf3856ad364e35”culture =“neutral”/> <bindingRedirect oldVersion =“0.0.0.0-2.0.0.0”newVersion =“2.0.0.0”/> </ dependentAssembly> </ assemblyBinding> </运行>

  • 获取Fusion日志:
*** Assembly Binder Log Entry  (2014-04-18 @ 01:10:23) ***

The operation failed.
Bind result: hr = 0x80131040. No description available.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.AspNet.Identity.EntityFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/Developer/sharp/projects/ShadowServer/DataModel/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Developer\sharp\projects\ShadowServer\DataModel\tmp2BEF.tmp
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.AspNet.Identity.EntityFramework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Developer/sharp/projects/ShadowServer/DataModel/bin/Debug/Microsoft.AspNet.Identity.EntityFramework.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Developer\sharp\projects\ShadowServer\DataModel\bin\Debug\Microsoft.AspNet.Identity.EntityFramework.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: Microsoft.AspNet.Identity.EntityFramework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Setup failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

对不起我的英语提前:)

1 回答

  • 0

    在我的情况下,我得到以下错误:

    无法加载文件或程序集“Microsoft.AspNet.Identity.EntityFramework,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35”或其中一个依赖项 . 定位的程序集的清单定义与程序集引用不匹配 .

    我意识到我的主要UI启动项目有旧版本的Microsoft.AspNet.Identity.EntityFramework by default ...(而在另一个数据层项目中我手动获取了最新的库)所以刚刚从NUGet更新了主项目 .

相关问题