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

lik*_*ski 7 c# asp.net-mvc azure visual-studio

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

无法从程序集'mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'加载类型'System.Runtime.CompilerServices.ExtensionAttribute'.

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

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

包括完整堆栈跟踪:

[TypeLoadException:无法从程序集'mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'加载类型'System.Runtime.CompilerServices.ExtensionAttribute'.]
System.ModuleHandle.ResolveType(RuntimeModule module,Int32 typeToken,IntPtr*typeInstArgs,的Int32 typeInstCount,IntPtr的*methodInstArgs,的Int32 methodInstCount,ObjectHandleOnStack型)0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule模块,的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 derivedAttribu tes,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:预应用程序启动初始化方法在类型WebActivator.ActivationManager上运行时抛出异常,并显示以下错误消息:无法从程序集'mscorlib,Version = 4.0.0.0,Culture中加载类型'System.Runtime.CompilerServices.ExtensionAttribute' = 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):预应用程序启动初始化方法运行类型WebActivator.ActivationManager引发异常,并显示以下错误消息:无法从程序集'mscorlib,Version = 4.0加载类型'System.Runtime.CompilerServices.ExtensionAttribute'. 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

lik*_*ski 1

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