为什么构建失败在Visual Studio中,因为它无法解析从引用的程序集的命名空间?因为它、程序、空间、Visual

2023-09-03 16:11:10 作者:娘们不毒何以立足

我有3个类库项目。让我们称他们为A,B和; C.我已经加入项目参考急症室; B插入项目℃。

A和B的建设没有任何错误或警告。

code(类文件)从项目C使用公共的类A和B. 当我添加项目引用在C中,并期待在类文件在C项目(建设项目c)之前,我可以清楚地看到,从A和所有类和命名空间; B被解决了。:当我在类名悬停我的鼠标(类从A或B),它显示了它的正确的命名空间了。

我有两个项目引用设置复制本地属性

不过,

当我运行重建所有(或建设项目C),因为它未能解决的命名空间构建失败!我可以进一步检查,以确保一切都正确完成? 我永远也找不到急症室的组件; B被复制到项目C.为什么不把它复制引用的斌\调试文件夹? (我已经看到了这个问题的几个问题,但没有提供给他们的解决方案,为我工作过) 解决方案

这个问题就解决了​​。问题是,项目℃的目标定位'.NET 4客户端配置文件的框架和A,B分别打靶'.NET 4的框架。当我改变的C目标框架,一切顺利建成。

答发布到这个问题,通过注册用户的帮助了我。

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.

Visual Studio Code的六个实用技巧

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,

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? 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)

解决方案

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.