Why is the build failing in Visual Studio because it cannot resolve namespaces from referenced assemblies?

点点圈 提交于 2020-01-22 17:15:49

问题


I have 3 class library projects. Lets call them A, B & C. I have added project reference of A & B into the project C.

A & B are building without any error or warning.

Code(Class file) from the project C uses public classes from A & B. When I add project reference in C and look at the class file (before building project C) in the C project, I can clearly see that all the classes and namespaces from A & B are resolved. When I hover my mouse on the class name (class from either A or B), it shows the correct namespace of it too.

I have set Copy Local property to True on both the project references.

However,

  1. When I run the Rebuild All (or Build on project C), build fails because it fails to resolve the namespaces! What can I check further to ensure everything is done correctly?
  2. I never find the assemblies of A & B copied into the bin\debug folder of the project C. Why does not it copy the reference? (I have seen several questions about this problem but none of the solutions provided to them have worked for me)

回答1:


The problem is solved. Problem was that project C was targetting '.NET 4 Client profile' framework and A, B were targetting '.NET 4' framework. When i changed target framework of C, everything built successfully.

Answer posted to this question by 'Registered User' helped me.




回答2:


Check if every project use the same Target framework. You can get that kind of error if for example one of the project uses .Net Framework 4 Client Profile and the rest uses .Net Framework 4 (not Client Profile)



来源:https://stackoverflow.com/questions/5499959/why-is-the-build-failing-in-visual-studio-because-it-cannot-resolve-namespaces-f

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