在Azure网站或Azure的云服务[错误] MVC4 API:“System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption” [英] MVC4 API on Azure WebSites or Azure Cloud Services [Error] : 'System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption'

查看:472
本文介绍了在Azure网站或Azure的云服务[错误] MVC4 API:“System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试我的Web API项目部署到云都网站和云托管服务在Azure上,我得到这个错误

I am getting this error when I try to deploy my Web API project to both Cloud WebSites and Cloud Hosted Services on Azure:

"{"ExceptionType":"System.TypeLoadException","Message":"Could not load type 'System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption' from assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.","StackTrace":"\r\nServer stack trace: \r\n   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)\r\n   at System.Reflection.RuntimeAssembly.GetExportedTypes()\r\n   at System.Web.Http.Dispatcher.DefaultHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver)\r\n   at System.Web.Http.WebHost.WebHostHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver)\r\n   at System.Web.Http.Dispatcher.HttpControllerTypeCache.InitializeCache()\r\n   at System.Lazy`1.CreateValue()\r\n\r\nException rethrown at [0]: \r\n   at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)\r\n   at System.Reflection.RuntimeAssembly.GetExportedTypes()\r\n   at System.Web.Http.Dispatcher.DefaultHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver)\r\n   at System.Web.Http.WebHost.WebHostHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver)\r\n   at System.Web.Http.Dispatcher.HttpControllerTypeCache.InitializeCache()\r\n   at System.Lazy`1.CreateValue()\r\n   at System.Lazy`1.LazyInitValue()\r\n   at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.InitializeControllerInfoCache()\r\n   at System.Lazy`1.CreateValue()\r\n\r\nException rethrown at [1]: \r\n   at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.SelectController(HttpRequestMessage request)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncInternal(HttpRequestMessage request, CancellationToken cancellationToken)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)"}"

下面就是消息:

"Could not load type 'System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption' from assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'."

当我尝试打我的任何的API,从远程站点它发生。我知道它不是我的500错误,因为不管发生什么我的一些API的习惯的把他们。

It happens when I try to hit any of my API's from the remote site. I know its not my 500 errors because some of my API's wont throw them regardless of what happens.

有一点要注意,我不知道这是否会影响什么是我开始这个项目针对.NET 4.5,但随后切换到4.0时,Azure网站表示,他们不支持4.5。

One thing to note and I am not sure if this would affect anything is I started this project targeted at .NET 4.5 but then switched it to 4.0 when Azure Web Sites said they don't support 4.5.

我找不到这事,除了此链接:
<一href=\"http://support.appharbor.com/discussions/problems/4822-internal-server-error-500-mvc-4-web-api\">http://support.appharbor.com/discussions/problems/4822-internal-server-error-500-mvc-4-web-api

I can't find anything about this except this link: http://support.appharbor.com/discussions/problems/4822-internal-server-error-500-mvc-4-web-api

除了那个家伙正在使用的应用程序海,andeven仍然仍然没有解决。感谢任何帮助。

except that guy is using app-harbor, andeven still there is still no solution. Thanks of any help.

推荐答案

所以它似乎是这个问题被我从4.5回滚到.NET 4和实体不回滚造成的。看来,实体5只能运行在.NET 4.5,当部署期待4.3.1它有一个5.0.0 DLL,它搞砸一切。

So it seemed that the problem was caused by me rolling back to .NET 4 from 4.5 and Entity not rolling back. It seems that Entity 5 only runs on .NET 4.5 and when the deployment was expecting 4.3.1 it had a 5.0.0 DLL and it messed everything up.

这篇关于在Azure网站或Azure的云服务[错误] MVC4 API:“System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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