无法解析引用的项目 [英] Can't resolve referenced projects

查看:57
本文介绍了无法解析引用的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个新的名为"TestIt"的ASP.NET 5 MVC项目.然后,我在解决方案中添加了一个新的名为"TestIt.ClassLibrary"的ASP.NET 5类库项目,并在MVC项目(即"TestIt")中引用了"TestIt.ClassLibrary".

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".

我遇到的问题是,我似乎无法访问类库项目中的任何方法-至少我可以说IntelliSense不能帮助我-见下文:

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?

我想指出的是,我更新了项目以使用DNX46(两个项目).还需要指出,类库是一个ASP.NET 5类库项目,可生成NuGet包.

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.

这是ASP.NET 5 MVC项目的project.json文件:

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" ]
  }
}

推荐答案

我遇到了类似的问题,但是设置有所不同.我有一个主要项目是.xproj,目标是dnx451和dnxcore50.我有一个类库,它是便携式类库"(.csproj).我尝试了可移植类库的不同配置.到我找到一个构建的库时,我已经搞砸了,因为intellisense对于引用类库中的类的任何代码都不起作用.

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.

我最终确定,当我要更改类库的目标"时,创建的wrap project.json文件从未得到更新.

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. 从主项目中的project.json中删除对类库的引用
  2. 关闭VS
  3. 删除解决方案目录中的"wrap"文件夹以及解决方案目录中的global.json文件.您可能要打开这些文件,并确保没有要保留的内容.就我而言,里面唯一的参考是我遇到问题的项目.
  4. 打开VS.
  5. 在主项目中添加对类库的引用,应该创建一个新的wrap文件夹和文件,希望这次是正确的.

从技术上讲,我要做的步骤比这还多.我重建了整个类库,但我不认为这是问题所在,如果是那样的话,您可以尝试使用适用于该构建的设置从头开始重建类库.

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!

这篇关于无法解析引用的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆