编译应用程序时,它会删除引用
我的 Visual Studio 项目遇到一个奇怪的问题。我正在使用 .Net 4 框架编写 C# 应用程序。我添加了对一些 DLL 的引用(我相信它们是在 3.5 中编译的),它们在我构建解决方案之前一直有效。发生这种情况时,它会删除引用,因为编译器无法看到这些 DLL 中的命名空间。有什么想法吗?
错误:
错误 4 找不到类型或命名空间名称“XXX”(您是 缺少 using 指令或程序集引用?)
I have a bizarre problem with a Visual Studio project. I'm writing a C# application using the .Net 4 framework. I add a reference to some DLLs (which I believe are compiled in 3.5) and they work until I build the solution. When this happens, it removes the References in the sense that the compiler cannot see the namespaces within these DLLs. Any ideas?
The error:
Error 4 The type or namespace name 'XXX' could not be found (are you
missing a using directive or an assembly reference?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经成功解决了这个问题。我检查了
项目属性
,发现它使用.Net 4 Client Profile
而不是.Net 4 Full
框架。将其更改为完整版本已经解决了我的问题。我认为该问题是由于Client Profile
中缺少System.Web
命名空间造成的。I have managed to resolve this problem. I checked the
Project Properties
and found that it was using.Net 4 Client Profile
rather than the.Net 4 Full
framework. Changing this to the full version has resolved my problem. I believe the problem is caused due to the lack of theSystem.Web
namespace within theClient Profile
.我建议您将这些 dll 文件存储在解决方案中的单独文件夹中,然后从新的文件夹中添加对它们的引用。将 dll 直接复制到 bin 目录时,我遇到了同样的问题。 VS 将在干净的构建中擦除所有这些 dll,因此它不是永久存储所述 dll 的理想选择。
另请注意:
尽管有一些选项应该可以防止我建议的情况发生,但从我个人的经验来看,它似乎仍然会发生,而且我们都知道 VS 并非没有错误! =P
I would recommend you store those dll files in a separate folder in your solution then add references to them from the new said folder. I have had the same exact issue when copying the dlls directly into the bin directory. VS will wipe all those dlls on a clean build so it is not an ideal candidate for permanent storage of said dlls.
Another note:
Despite the options that are supposed to prevent the scenario I suggested, it still seems to happen from my own personal experience and we all know VS isn't bug free! =P