VS2010: Use namespace from another project within the solution?

我与影子孤独终老i 提交于 2020-06-24 04:13:09

问题


I have two projects within a single solution in Visual Studio 2010. These projects are called Project1 and Project2. Within these projects, two namespaces are defined, Namespace1 and Namespace2, respectively.

Inside some code within Namespace2, I'd like to use some structs, classes, etc. which I've defined in Namespace1. Is there any way to do this?


回答1:


Yes, add a reference to Project1 from Project2. Right-click the project, choose "Add References" then from the "Projects" tab, choose Project1.




回答2:


In some cases you have to actually add the DLL of the other project to compile against, not just a reference to the project. Make sure copy to local is enabled in that advent.

I had this happen trying to link a console app to an MVC project.



来源:https://stackoverflow.com/questions/4416879/vs2010-use-namespace-from-another-project-within-the-solution

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