简体   繁体   中英

VS2010: Use namespace from another project within the solution?

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?

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

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.

确保在创建对它的引用之前构建项目,否则它不会显示。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM