我正在使用cloud sql跟随书架教程: https://cloud.google.com/dotnet/getting-started/using-cloud-sql
在我的localmachine上运行应用程序时,应用程序运行正常。
将应用程序部署到Compute Engine时。服务器显示无法读取的运行时错误。
<customErrors mode="Off"/>
无助于显示错误。
通过RDP连接并在远程桌面上观看localhost上的应用程序时,会显示以下错误:
Server Error in '/' Application.
Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[FileLoadException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
WebMatrix.WebData.PreApplicationStartCode.Start() +0
[InvalidOperationException: The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +874
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +169
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +133
System.Web.Compilation.BuildManager.ExecutePreAppStart() +176
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +734
[HttpException (0x80004005): The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +712
我无法声明应用程序为什么会出现此错误,因为我没有在项目中找到某种类型的引用到Razor的2.0.0.0版本。
System.Web.WebPages.Razor 3.0.0.0版包含在项目参考中。
降级到Razor版本2是否明智还是有其他解决方案?
答案 0 :(得分:1)
那么,有一个依赖于2.0版本,但你的系统上安装了3.0版本?在这种情况下,您可以尝试将绑定重定向从2.0声明为3.0。以下是有关如何声明绑定重定向的更多信息:
https://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx
答案 1 :(得分:0)
解决问题的整体解决方案是:
在声明绑定重定向到以下错误后显示:
尝试使用安全透明方法'WebMatrix.WebData.PreApplicationStartCode.Start()'来访问安全关键方法'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)'失败。
这可以通过
解决之后显示以下错误
无法加载文件或程序集'WebMatrix.Data,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)
这可以通过
解决