本文介绍了EntityFramework错误:提供程序未返回ProviderManifest实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目使用的是Visual Studio 2012 for Web Express的C#中的ASP.NET MVC4.

My project is using ASP.NET MVC4, in C# with Visual Studio 2012 for Web Express.

编译项目时,出现以下错误:

When compiling my project, I have the following error:

经过数小时的搜索,我认为错误与Entity Framework有某种关系.我还在这里找到了解决此错误的方法: http://forums.devart.com/viewtopic.php?f=32&t=25748

After many hours of search I believe that is error is somehow related to Entity Framework. I also found a work around for this error here: http://forums.devart.com/viewtopic.php?f=32&t=25748

解决方法建议我将.edmx文件中的字段ProviderManifestToken="2012"更改为ProviderManifestToken="2008".

The workaround suggests that I change the field ProviderManifestToken="2012" to ProviderManifestToken="2008" in my .edmx file.

这样做之后,错误消失了.但是当我运行项目时,我又遇到了另一个问题,运行时错误:

After doing that the error goes away. But then I have another problem when I run the project, a runtime error:

===预绑定状态信息===
日志:DisplayName = Microsoft.Data.Edm
(部分)
WRN:为组装提供了部分装订信息:
WRN:程序集名称:Microsoft.Data.Edm |域ID:2
WRN:当仅提供部分程序集显示名称时,发生部分绑定.
WRN:这可能导致活页夹加载错误的程序集.
WRN:建议为程序集提供完全指定的文本标识,
WRN:由简单的名称,版本,区域性和公共密钥令牌组成.
WRN:有关更多信息,请参见白皮书 http://go.microsoft.com/fwlink/?LinkId=109270 和此问题的常见解决方案.
日志:Appbase = file:///C:/Users/Pedro/Documents/Visual Studio 2012/Projects/Dockis/Development/Dockis/Dockis/
日志:初始PrivatePath = C:\ Users \ Pedro \ Documents \ Visual Studio 2012 \ Projects \ Dockis \ Development \ Dockis \ Dockis \ bin
调用程序集:(未知).

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Data.Edm
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Microsoft.Data.Edm | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/Pedro/Documents/Visual Studio 2012/Projects/Dockis/Development/Dockis/Dockis/
LOG: Initial PrivatePath = C:\Users\Pedro\Documents\Visual Studio 2012\Projects\Dockis\Development\Dockis\Dockis\bin
Calling assembly : (Unknown).

LOG:此绑定在默认的加载上下文中启动.
日志:使用应用程序配置文件:C:\ Users \ Pedro \ Documents \ Visual Studio 2012 \ Projects \ Dockis \ Development \ Dockis \ Dockis \ web.config
日志:使用主机配置文件:C:\ Users \ Pedro \ Documents \ IISExpress \ config \ aspnet.config
日志:使用C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ config \ machine.config中的计算机配置文件.

LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Pedro\Documents\Visual Studio 2012\Projects\Dockis\Development\Dockis\Dockis\web.config
LOG: Using host configuration file: C:\Users\Pedro\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.

LOG:当前未将策略应用于引用(私有,自定义,部分或基于位置的程序集绑定).
日志:尝试下载新的URL文件:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm.DLL.
日志:尝试下载新的URL文件:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm/Microsoft.Data.Edm .DLL.
日志:尝试下载新的URL文件:///C:/Users/Pedro/Documents/Visual Studio 2012/Projects/Dockis/Development/Dockis/Dockis/bin/Microsoft.Data.Edm.DLL.
日志:使用应用程序配置文件:C:\ Users \ Pedro \ Documents \ Visual Studio 2012 \ Projects \ Dockis \ Development \ Dockis \ Dockis \ web.config
日志:使用主机配置文件:C:\ Users \ Pedro \ Documents \ IISExpress \ config \ aspnet.config
日志:使用来自C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ config \ machine.config的计算机配置文件.
日志:在应用程序配置文件中找到重定向:5.6.0.0重定向到5.6.1.0.
日志:政策后参考:Microsoft.Data.Edm,Version = 5.6.1.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35
日志:尝试下载新的URL文件:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm.DLL.
日志:尝试下载新的URL文件:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm/Microsoft.Data.Edm .DLL.
日志:尝试下载新的URL文件:///C:/Users/Pedro/Documents/Visual Studio 2012/Projects/Dockis/Development/Dockis/Dockis/bin/Microsoft.Data.Edm.DLL.
WRN:比较程序集名称会导致不匹配:内部版本号
ERR:无法完成装配的设置(hr = 0x80131040).探测终止.

LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm/Microsoft.Data.Edm.DLL.
LOG: Attempting download of new URL file:///C:/Users/Pedro/Documents/Visual Studio 2012/Projects/Dockis/Development/Dockis/Dockis/bin/Microsoft.Data.Edm.DLL.
LOG: Using application configuration file: C:\Users\Pedro\Documents\Visual Studio 2012\Projects\Dockis\Development\Dockis\Dockis\web.config
LOG: Using host configuration file: C:\Users\Pedro\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 5.6.0.0 redirected to 5.6.1.0.
LOG: Post-policy reference: Microsoft.Data.Edm, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm/Microsoft.Data.Edm.DLL.
LOG: Attempting download of new URL file:///C:/Users/Pedro/Documents/Visual Studio 2012/Projects/Dockis/Development/Dockis/Dockis/bin/Microsoft.Data.Edm.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

堆栈跟踪:

[FileLoadException: Could not load file or assembly 'Microsoft.Data.Edm' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]

[FileLoadException: Could not load file or assembly 'Microsoft.Data.Edm, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Data.Edm, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +285
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521

[HttpException (0x80004005): Could not load file or assembly 'Microsoft.Data.Edm, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9950728
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Dockis是项目的名称.看到此错误后,我花了几个小时认为错误在于所使用软件包的版本中.但是,事实并非如此,因为大多数软件包都是最新的,而且它们之间似乎没有任何冲突.

Dockis is the name of the project. After seeing this error I spent several hours believing that the errors lied somewhere in the versions of the package being used. However, this does not seem to be the case, since the majority of packages are up to date and there doesn't seem to be any conflicts between them.

因此,我重新相信问题出在EntityFramework的版本上,但是我对如何解决此问题没有想法.

Consequently, I am back to believing that the problem lies with the version of EntityFramework, but I am out of ideas on how to fix this.

我很高兴,如果您有任何建议,我将不胜感激.

I'm all ears, if you have any suggestions, I'll appreciate them.

推荐答案

显然,问题出在我使用的Visual Studio版本.如果你问我的话,请注意.在删除Visual Studio Web Express 2012并安装Visual Studio 2013 Ultimate之后,一切都会按预期开始工作.

Aparently, the problem was the Visual studio version that I was using. Mind blowing if you ask me. After removing Visual Studio Web Express 2012 and installing Visual Studio 2013 Ultimate everything started working as it should.

这篇关于EntityFramework错误:提供程序未返回ProviderManifest实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 11:14