简体   繁体   中英

Add reference to other C# projects in visual studio 2015

I have a C# console application project in visual studio 2015. I have a project with name MyPrograms in this solution. There are some classes and a main test method in this project. I have another (C# Unit Test ) project in the same solution with name MyUnitTests .
I have set the target framework of MyPrograms to .Net Framework 4 Client Profile and .Net Framework 4.5 of MyUnitTests project. I have also added the reference of MyPrograms project in my MyUnitTests project.

Now I want to access class files of MyPrograms project in my MyUnitTests project. I am accessing class files of MyPrograms project with the using statements in the classes of MyUnitTests project. But I am unable to access those classes.

I have also tried it by changing various target frameworks of both the projects. I have tried different things as well as explained in the following links.

https://msdn.microsoft.com/en-us/library/ez524kew.aspx https://msdn.microsoft.com/library/ez524kew(v=vs.110).aspx

The same problem was solved in my case by following these things. If your MyPrograms project is a console application, it will generate exe file but not dll file. In your MyUnitTests project, add reference of both .exe file and .vshost from path YourProject/bin/Debug/... Also try to change Platform to x64 from configuration manager and build your both projects. Also to Any CPU if previously was x64 and again build both the solutions.

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