asp.net-core MVC rc2在linux上使用net451

时间:2016-06-06 20:12:40

标签: asp.net-core asp.net-core-mvc .net-core-rc2

我正在尝试将我的网站从dotnet核心rc1迁移到dotnet核心rc2,但我遇到了一个错误,然后我尝试运行一个小测试,它也不适用于我。 这是我的箴言:https://github.com/ricardoalcantara/WebApplicationBasic

我的环境是:

  • Debian 8.4
  • Mono 4.2.3
  • dotnet 1.0.0-preview1-002702

我需要在“框架”:“net451”之上运行它,因为我的主项目需要很少的库仍然只能在该平台上运行,所以我使用这个命令行运行:

dotnet run --framework .NETFramework,Version=v4.5.1

它实际上运行,但是当我尝试访问localhost:5000时,它会主要使用该消息抛出一个长堆栈错误:

z2cw6v06.4ja(43,10): error CS0518: Predefined type 'System.Object' is not defined or imported
z2cw6v06.4ja(43,50): error CS0012: The type 'Attribute' 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'.
z2cw6v06.4ja(43,10): error CS0518: Predefined type 'System.Void' is not defined or imported
z2cw6v06.4ja(45,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'.
z2cw6v06.4ja(45,10): error CS0518: Predefined type 'System.Object' is not defined or imported
z2cw6v06.4ja(45,50): error CS0012: The type 'Attribute' 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'.
z2cw6v06.4ja(45,10): error CS0518: Predefined type 'System.Void' is not defined or imported
z2cw6v06.4ja(47,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'.
z2cw6v06.4ja(47,10): error CS0518: Predefined type 'System.Object' is not defined or imported
z2cw6v06.4ja(47,50): error CS0012: The type 'Attribute' 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'.

有人可以帮我解决这个问题吗?

Obs。:适用于Windows。

1 个答案:

答案 0 :(得分:0)

如果仔细观察,错误似乎是MVC无法编译视图:

Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException: One or more compilation failures occurred:
pufduf6v.a1v(17,88): error CS1980: Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference?
pufduf6v.a1v(17,88): error CS0518: Predefined type 'System.Boolean' is not defined or imported
pufduf6v.a1v(17,47): 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'.
…

但是运行dotnet publish然后使用mono直接执行结果对我有用,例如(在Ubuntu上):

mono bin/Debug/net451/ubuntu.14.04-x64/publish/WebApplicationBasic.exe

As was already explained to you on Github, this seems to be a known issue.