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":"
Server stack trace:
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at System.Web.Http.Dispatcher.DefaultHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver)
at System.Web.Http.WebHost.WebHostHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver)
at System.Web.Http.Dispatcher.HttpControllerTypeCache.InitializeCache()
at System.Lazy`1.CreateValue()
Exception rethrown at [0]:
at System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes)
at System.Reflection.RuntimeAssembly.GetExportedTypes()
at System.Web.Http.Dispatcher.DefaultHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver)
at System.Web.Http.WebHost.WebHostHttpControllerTypeResolver.GetControllerTypes(IAssembliesResolver assembliesResolver)
at System.Web.Http.Dispatcher.HttpControllerTypeCache.InitializeCache()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.InitializeControllerInfoCache()
at System.Lazy`1.CreateValue()
Exception rethrown at [1]:
at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.SelectController(HttpRequestMessage request)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsyncInternal(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)"}"
Here is just the message:
"Could not load type 'System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption' from assembly 'System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'."
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.
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.
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
except that guy is using app-harbor, andeven still there is still no solution. Thanks of any help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…