为什么我的项目参考可以正常工作,但一旦构建解决方案,参考就会失败?
我在一个解决方案下有多个项目。我从项目 B 添加对项目 A 的引用。现在我可以添加“using ProjectA.Models;” (智能感知有效!)到项目 B 中的类,因为它现在有了引用,并且自定义对象的关键字着色有效,自动完成/智能感知一切正常......
直到我构建我的解决方案。突然,我遇到了引用失败,我添加的“using”行变成了红色下划线,并且所有对象引用都失去了关键字颜色。
我可以通过删除并重新创建引用来无限期地重复该过程,这使得 IDE 可以很好地处理“using ProjectA;”和所有智能感知,直到我再次点击构建。
是什么原因造成的?
更新:天哪,这让我发疯,我找不到任何东西来解释这一点!我添加项目引用,然后转到代码并开始输入:
使用 P
现在突然自动完成显示 ProjectA{} 的其余部分
,我可以继续添加 .Models{},它也会自动完成。
当我为整个解决方案或只是项目点击“构建”时,突然出现错误:
找不到类型或命名空间...
此时,如果我再次查看代码并开始输入:
使用 P
NO AUTO完成,它再也找不到参考了...WTF。
我要把这台机器扔出窗外。
I have multiple projects under one solution. I add a reference to Project A from Project B. Now I can add 'using ProjectA.Models;' (intellisense works!) to classes in Project B because it now has the reference, and the keyword coloring for custom objects works, the autocomplete/intellisense all works fine...
Right until I build my solution. Suddenly I get a reference failure, the 'using' line that I added becomes underlined with red, and all the object references lose their keyword coloring.
I can repeat the process indefinitely by removing and recreating the reference, which allows the IDE to be fine with 'using ProjectA;' and all intellisense, right up until I hit build again.
What is causing this?
Update: Holy crap this is driving me nuts, I can't find ANYTHING to explain this!! I add the project reference and then go to the code and start typing:
using P
now suddenly auto complete shows the rest of it ProjectA{}
and I can keep going and add .Models{} and it will auto complete that as well.
As SOON as I hit Build for the entire Solution OR just the project, suddenly I get an error:
Type or namespace could not be found...
At this point if I go up to the code again and start typing:
using P
NO AUTO COMPLETE, it can no longer find the reference anymore... WTF.
I am going to throw this machine out the window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论