Can't resolve referenced projects

喜你入骨 提交于 2019-12-25 03:34:59

问题


I created a new ASP.NET 5 MVC project named "TestIt". I then added a new ASP.NET 5 Class Library project named "TestIt.ClassLibrary" to my solution and referenced "TestIt.ClassLibrary" to the MVC project i.e. "TestIt".

The problem I'm having is that I can't seem to access any of the methods in the class library project -- at least I can say that IntelliSense is not helping me -- see below:

Any idea why I'm having this problem?

I want to point out that I updated the projects to use DNX46 (both of them). Also want to point out that the class library is an ASP.NET 5 Class Library project which generates NuGet packages.

Here's the project.json file for the ASP.NET 5 MVC project:

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

  "dependencies": {
    "TestIt.ClassLibrary": "1.0.0-*",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Facebook": "1.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Google": "1.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.OAuth": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "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",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"
  },

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

  "frameworks": {
    "dnx46": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ],
  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
  }
}

回答1:


Check your project.json file to ensure that you have a dependency reference to your class library.

It should look something like this:

"dependencies": {
      "TestIt.ClassLibrary": "1.0.0-*",

EDIT: Add this to the top of your project file to see if it resolves the intellisense.

"webroot": "wwwroot",



回答2:


I had a similar issue, but the setup was different. I have a primary project that is a .xproj and targets dnx451 and dnxcore50. I have a class library that is a "Portable Class Library" (.csproj). I experimented with different configurations of the portable class library. By the time I found one that built I had messed something up because intellisense didn't work for any code that referenced classes in the class library.

I eventually determined that the wrap project.json files that were created never got updated when I would change my class library's "targets".

This may or may not be your problem. I don't even know if a wrap folder would be created in your scenario.

I resolved my issue by:

  1. Removing the references to the class library from project.json in my main project
  2. Closing VS
  3. Deleting the "wrap" folder in the solution directory and also the global.json file in the solution directory. You may want to open these files and make sure there isn't anything you want to keep. In my case the only references inside were to the project I was having issues with.
  4. Open VS.
  5. Add the reference to your class library in your primary project, a new wrap folder and file should get created, and hopefully it is correct this time.

Technically I did more steps than this. I rebuilt my entire class library, but I don't think that was the problem, if it was then you might try rebuilding your class library from scratch with the settings that are working for the build.

Good luck, I hope this helps!



来源:https://stackoverflow.com/questions/34476870/cant-resolve-referenced-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!