MVC4:程序集的清单定义与程序集引用不匹配
本文关键字:程序集 定义 引用 不匹配 单定义 MVC4 | 更新日期: 2023-09-27 18:34:36
我是MVC的新手,所以请忍受一点迷失方向。我有一个包含以下项目的 .NET 4.5 解决方案:
- Parkalot.Entity (包含实体类(
- Parkalot.Database (包含数据上下文类(
- Parkalot.Mvc4AspxClient (The Web client(
所有项目都已使用 NuGet 使用 EntityFramework 5 进行配置,所有项目都面向 .NET 4.5。全部设置为"任何 CPU"。Visual Studio 2013 Ultimate Preview on 64 bit Winddows 8 Pro(这并不重要(。
如果我尝试使用数据上下文从 Web 客户端的 Global.asax 访问数据库,它工作正常,因此直到 Web 客户端为止都没有问题。
添加控制器时,只要我选择[Empty MVC Controller]
模板,它就可以正常工作。当我尝试添加模板类型为 [MVC Controller with read/write actions and views, using Entity Framework]
的控制器并选择 Parkalot.Entity.Tenant 作为模型类并选择 Parkalot.Database.Context 作为数据上下文类时,我收到以下错误:
Unable to retrieve metadata for 'Parkalot.Entity.Tenant'. Could not load file or assembly
'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or
one of its dependencies. The located assembly's manifest definition does not match the
assembly reference. (Exception from HRESULT: 0x80131040)
如果它是相关的,我还会收到以下编译时警告:
C:'...'Microsoft.Common.CurrentVersion.targets(1613,5): warning MSB3247:
Found conflicts between different versions of the same dependent assembly.
Please add the following binding redirects to the "runtime" node in your
application configuration file:
- Parkalot.Mvc4AspxClient ->
C:'...Parkalot.Mvc4AspxClient'bin'Parkalot.Mvc4AspxClient.dll
该解决方案最初是在VS2010中创建的,然后升级到VS 2013和.NET 4.5。我想知道这是否是原因,但仍然不知道如何解决它。
编辑:当搜索版本4.4.0.0时,如错误所示,我发现以下内容!
C:'...'Parkalot.WinFormsClient'App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:'...'Parkalot.WinFormsClient'Visual Studio'app.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
C:'...'Parkalot.Library'App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:'...'Parkalot.Library'Visual Studio'App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
C:'...'Parkalot.Entity'App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:'...'Parkalot.Entity'Visual Studio'App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
C:'...'Parkalot.Database'App.config(8):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:'...'Parkalot.Business'App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:'...'Parkalot.Business'Visual Studio'App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
C:'...'Parkalot.Configuration'App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:'...'Parkalot.Test'App.config(5):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:'...'Parkalot.WebFormsClient'Web.config(9):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
C:'...'Parkalot.Mvc4AspxClient'Web.config(9):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
C:'...'Parkalot.Mvc4RazorClient'Web.config(9):
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
基于错误
Unable to retrieve metadata for 'Parkalot.Entity.Tenant'. Could not load file or assembly
'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or
one of its dependencies. The located assembly's manifest definition does not match the
assembly reference. (Exception from HRESULT: 0x80131040)
此错误的可能原因可能是 EF 版本。并且您已经从VS2010升级,似乎解决方案仍在搜索上述程序集的指定版本,但实际上VS2012使用不同的版本。EF5 在 .Net Framework 4.5 上运行。
- 展开"引用"并检查 EF 版本。
- 检查升级日志中是否有任何错误和警告。
我遇到了同样的问题,并通过从''bin目录中删除文件来解决它。