2016-08-03 90 views
3

我有一個正在運行的ASP.NET 5 RC1應用程序。現在我已經將Shawn Wildermuth博客的幫助下的應用程序轉換爲當前的ASP.NET Core 1.0.0版本。 api控制器的運行沒有任何問題。但只要我嘗試打開一個* .cshtml文件,我收到以下錯誤:將ASP.NET從RC1升級到核心後的Razor異常

Microsoft.AspNetCore.Server.Kestrel: Error: Connection id "0HKTRFIA80GPS": An unhandled exception was thrown by the application.

Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException: One or more compilation failures occurred:

rkq2e32e.x02(16,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)

...

rkq2e32e.x02(37,10): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

rkq2e32e.x02(37,10): error CS0518: Predefined type 'System.Object' is not defined or imported

是否有人有一個想法,我可以開始?

回答

1

我通過比較project.json和正在運行的ASP.NET Core版本中的新project.json,找到了異常的原因。其實我沒有找到原因 - 我剛剛發現添加preserveCompilationContext之後異常消失 - 真正進入我的project.json:

"buildOptions": { 
    "emitEntryPoint": true, 
    "preserveCompilationContext": true 
}