I have created a project container In Visual studio. In this container, I have added three projects: A class library, a ASP .NET MVC Application and a Unit Test application.
我在Visual studio中创建了一个项目容器。在这个容器中,我添加了三个项目:一个类库、一个asp.net MVC应用程序和一个单元测试应用程序。
Now, Im trying to add references between this projects. When Im trying to add a reference to my class library from my .NET MVC Application, I get an error that says that the reference could not be added.
现在,我试着在这些项目之间添加参考资料。当我尝试在. net MVC应用程序中添加对我的类库的引用时,我得到了一个错误,它说不能添加引用。
Why do I get this error? Why can't I add a reference from my class library, to my mvc application?
为什么会出现这个错误?为什么我不能从我的类库中添加一个引用到我的mvc应用程序中呢?
2 个解决方案
#1
1
For future reference you really need to tell the versions on what you're using : Visual Studio?, ASP.NET MVC?, and .net Framework? as Ufuk mentioned. I'll assume you mean ASP.NET 5 vNext, as I know this has an issue.
为了将来的参考,你真的需要告诉你所使用的版本:Visual Studio?,ASP。净MVC吗?,. net框架?正如Ufuk提到。我猜你是说ASP。NET 5 vNext,我知道这有问题。
Firstly, look at other posts: Issue adding reference to class library project in ASP.NET 5 (Core)
首先,看看其他文章:在ASP中发布类库项目的添加参考。净5(核心)
And secondly, if it's similar to what I experienced, there appears to be a bug in the beta7, so try adding a file reference: https://*.com/a/32399377/2537017
其次,如果它类似于我的经历,那么beta7中似乎有一个bug,所以请尝试添加一个文件引用:https://*.com/a/32399377/2537017
(That's assuming you've removed the dnxcore50 so it can use the new class library).
(假设您已经删除了dnxcore50,以便它可以使用新的类库)。
#2
0
I had such problem, and I found it's cause of post build setting on referred library project, in post build I was copying some un-managed native dll into output directory, by removing the post build event my problem solved.
我遇到了这样的问题,我发现这是由于在引用库项目上的后构建设置的原因,在后构建中,我将一些非托管的本地dll复制到输出目录中,通过删除我解决的后构建事件。
#1
1
For future reference you really need to tell the versions on what you're using : Visual Studio?, ASP.NET MVC?, and .net Framework? as Ufuk mentioned. I'll assume you mean ASP.NET 5 vNext, as I know this has an issue.
为了将来的参考,你真的需要告诉你所使用的版本:Visual Studio?,ASP。净MVC吗?,. net框架?正如Ufuk提到。我猜你是说ASP。NET 5 vNext,我知道这有问题。
Firstly, look at other posts: Issue adding reference to class library project in ASP.NET 5 (Core)
首先,看看其他文章:在ASP中发布类库项目的添加参考。净5(核心)
And secondly, if it's similar to what I experienced, there appears to be a bug in the beta7, so try adding a file reference: https://*.com/a/32399377/2537017
其次,如果它类似于我的经历,那么beta7中似乎有一个bug,所以请尝试添加一个文件引用:https://*.com/a/32399377/2537017
(That's assuming you've removed the dnxcore50 so it can use the new class library).
(假设您已经删除了dnxcore50,以便它可以使用新的类库)。
#2
0
I had such problem, and I found it's cause of post build setting on referred library project, in post build I was copying some un-managed native dll into output directory, by removing the post build event my problem solved.
我遇到了这样的问题,我发现这是由于在引用库项目上的后构建设置的原因,在后构建中,我将一些非托管的本地dll复制到输出目录中,通过删除我解决的后构建事件。