添加PCL引用会导致“System.Object未定义”错误

时间:2016-03-02 14:09:36

标签: asp.net asp.net-core

我有一个这个项目的PCL.json:

 {
  "supports": {
    "net46.app": {},
    "uwp.10.0.app": {},
    "dnxcore50.app": {}
  },
  "dependencies": {
    "Microsoft.NETCore": "5.0.0",
    "Microsoft.NETCore.Portable.Compatibility": "1.0.0",
    "System.ServiceModel.Primitives": "4.0.0"
  },
  "frameworks": {
    "dotnet": {
      "imports": "portable-net452+win81"
    }
  }
}

当我添加对我的asp.net 5 web应用程序的引用时,生成的web应用程序的project.json看起来像这样:

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel"
  },

  "frameworks": {
    "dnx451": {
      "dependencies": {
        "MyPcl": "1.0.0-*"
      }
    },
    "dnxcore50": {
      "dependencies": {
        "MyPcl": "1.0.0-*"
      }
    }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}

根据我的判断,这应该是正确的,但它会导致网络应用中的一些错误:

  

预定义类型'System.Object'未定义或导入MyWebApp.DNX 4.5.1 C:\ source \ MyWebAppStartup.cs

     

预定义类型'System.Void'未定义或导入MyWebApp.DNX 4.5.1 C:\ source \ MyWebApp \ Startup.cs

我找到了100种方法来解决这个问题,没有一种方法可以解决,而我只是没有得到它。任何帮助,将不胜感激。 (我使用VS2015)

编辑:重启VS解决了这些错误。现在只有这个错误

  

对象引用未设置为对象的实例。 MyWebApp C:\ source \ MyWebApp \ DNX 1

0 个答案:

没有答案