How can I refer to a project from another one in c#?

前端 未结 9 1143
孤街浪徒
孤街浪徒 2020-12-01 12:13

I added a project, Project2, to my solution. It already had another project lets say Project 1. How can I call classes and methods from project2 into project1?

What

9条回答
  •  鱼传尺愫
    2020-12-01 12:32

    I just had this very same problem. I triple checked everything, and references were added, project was in the same solution, everything set. I also know my namespaces, I even got code completion but when building, I got the same error that the namespace cannot be found.

    It took me one hour to find this out: The project I added, that didn't find the respective namespace, was set to a different .NET target framework. I changed my solution to the "full" .NET Framework 4 instead of the Client Profile 4, but the new project I added was set to the Client Profile again.

    Instead of giving me a proper warning about the bad configuration, it claimed that namespaces could't be found.

    Hope this helps someone, and saves you the time that I just wasted.

提交回复
热议问题