实体框架不适用于已发布的WCF服务 [英] Entity Framework does not work on published WCF service

查看:75
本文介绍了实体框架不适用于已发布的WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个托管在网站上的WCF服务,但是我可以使Entity Framework与其一起使用.一切在本地都可以正常运行,但不能在服务器上运行.我收到以下异常:

I have an WCF service that is hosted on a web site, but i can get Entity Framework to work with it. Everything works fine locally but not on the server. I get the following exception:

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.


堆栈跟踪:


Stack trace:

at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)  at System.Reflection.Assembly.GetTypes() at System.Data.Metadata.Edm.ObjectItemAttributeAssemblyLoader.LoadTypesFromAssembly()  at System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load()   at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData)  at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, KnownAssembliesSet knownAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage, Object& loaderCookie, Dictionary`2& typesInLoading, List`1& errors)\r\n   at System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage)\r\n   at System.Data.Metadata.Edm.ObjectItemCollection.ImplicitLoadAssemblyForType(Type type, EdmItemCollection edmItemCollection)\r\n   at System.Data.Metadata.Edm.MetadataWorkspace.ImplicitLoadAssemblyForType(Type type, Assembly callingAssembly)  at System.Data.Objects.ObjectContext.GetTypeUsage(Type entityCLRType)\r\n   at System.Data.Objects.ObjectContext.GetEntitySetFromContainer(EntityContainer container, Type entityCLRType, String exceptionParameterName) at System.Data.Objects.ObjectContext.GetEntitySetForType(Type entityCLRType, String exceptionParameterName)



很抱歉,我无法提供更多详细信息,但这是因为我不知道发生了什么.如果需要其他任何详细信息来解决此问题,请告诉我,我将其发布.我检查了以下内容:

1. .net版本在所有项目上都相同.
2.在所有引用上,本地复制"均设置为"True".



I''m sorry that I''m not able to provide more details, but this is because i don''t know what is going on. If there are any other details needed to solve this problem please let me know, i will post them. I have checked the following:

1. .Net version is the same on all projects.
2. Copy Local is set to "True" on all references.

推荐答案

最后解决了它.我的图书馆项目引用了System.Web.Mvc,因此我不得不将以下dll复制到Bin文件夹中:

Microsoft.Web.Infrastructure.dll
System.Web.Mvc.dll
System.Web.Razor.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.dll
System.Web.WebPages.Razor.dll

我不明白的是,如果我在发布网站时在图书馆项目中的引用上将本地副本设置为"true",为什么不包含该副本.
Finally solved it. My library project referenced System.Web.Mvc so i had to copy the following dll''s to the Bin-folder:

Microsoft.Web.Infrastructure.dll
System.Web.Mvc.dll
System.Web.Razor.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.dll
System.Web.WebPages.Razor.dll

What i don''t understand is, if i set the copy local to "true" on a reference inside a library project why isn''t it included, when i publish the web site.


这篇关于实体框架不适用于已发布的WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆