2016-08-03 53 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 
} 
相关问题