gpt4 book ai didi

c# - 将 MVC4 站点部署到 Azure 会导致 ExtensionAttribute 异常

转载 作者:太空狗 更新时间:2023-10-29 20:40:11 25 4
gpt4 key购买 nike

在观看了 Scott Gu 在 AspConf 上的主题演讲之后,我对尝试使用 MVC4 的 Windows Azure 网站感到非常兴奋。我尝试在将现有 MVC 应用程序重新配置为目标 .NET Framework 4.0 而不是 4.5 后部署它,并收到以下错误。

Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

由于我已经添加了几个 NuGet 包,我认为它可能与 Ninject 有关,因此我创建了一个针对 .NET 4.0 框架的新 MVC 项目,没有 NuGet 包,并使用 Visual Studio 2012 RC Publish 部署到 Windows Azure选项(右键单击 Web 项目),但我仍然收到此错误。

有谁知道发生了什么事或如何解决这个问题?提前致谢。

包括完整的堆栈跟踪:

[TypeLoadException: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +180
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +192
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +115
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +426 System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +103
System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit) +64
WebActivator.AssemblyExtensions.GetActivationAttributes(Assembly assembly) +64 WebActivator.ActivationManager.RunActivationMethods() +143 WebActivator.ActivationManager.Run() +22

[InvalidOperationException: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'..]
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +423
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +306
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +677

[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'..]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9090044 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256

最佳答案

在发布 Web 应用程序向导中,如果我选择设置 |删除目标位置的其他文件,此问题就消失了。

关于c# - 将 MVC4 站点部署到 Azure 会导致 ExtensionAttribute 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11571524/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com