2016-10-10 45 views
0

我正在關注的書架教程使用Cloud SQL: https://cloud.google.com/dotnet/getting-started/using-cloud-sql使用雲SQL和.NET書架教程

當運行在我LOCALMACHINE應用程序工作正常的應用程序。

將應用程序部署到計算引擎時。服務器顯示無法讀取的運行時錯誤。

<customErrors mode="Off"/> 

無助於顯示錯誤。

當連接直通RDP和觀看顯示在下面的錯誤上的遠程桌面本地主機的應用程序:

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. 聲明綁定重定向https://stackoverflow.com/a/39999353/2629901作爲對這個職位回答@Mete Atamel

聲明綁定重定向到以下錯誤之後被示出:

嘗試通過安全透明方法'WebMatrix.WebData.PreApplicationStartCode.Start()'訪問安全關鍵方法'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)'失敗。

這可以通過

來解決如在 https://stackoverflow.com/a/19568376/2629901

提到

  • 安裝-封裝Microsoft.AspNet.WebHelpers用的NuGet控制檯,以下錯誤後顯示爲

    無法加載文件或程序集'WebMatrix.Data,Version = 3.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'或其中之一依賴關係。定位的程序集清單定義與程序集引用不匹配。(從HRESULT異常:0x80131040)

    這可以通過

    要解決
  • 安裝-封裝Microsoft.AspNet.WebPages.Data用的NuGet控制檯如https://stackoverflow.com/a/22587521/2629901
  • 提到