简体   繁体   English

vs2010-参考.exe不起作用

[英]vs2010 - reference .exe not working

I've got a project (project A)in vs2010 (c#) that I want to reference another project (.exe) (project B) that I created. 我在vs2010(c#)中有一个项目(项目A),我想引用我创建的另一个项目(.exe)(项目B)。 Project A is a quick, down & dirty util that I will only use once but I need all the function calls and db calls from project B, so rather than cut, copy, pasting from one to another, I thought I could just reference project B in my references. 项目A是一种快速,精简且肮脏的工具,我只使用一次,但是我需要项目B的所有函数调用和数据库调用,因此与其剪切,复制,粘贴到另一个,我还想参考一下项目B在我的参考文献中。 I am able to point to the .exe and in code i can use it, but when I compile it, it complains about not being able to see it (the infamous "are you missing a using directive or assembly reference?" error). 我可以指向.exe,并且可以在代码中使用它,但是当我编译它时,它抱怨无法看到它(臭名昭著的“您是否缺少using指令或程序集引用?”错误)。

Does anyone know how I can do this? 有人知道我该怎么做吗?

Most probably, also it's hard to say , you have .NET Framework version conflict. 很有可能, 也很难说 ,您有.NET Framework版本冲突。 One of your projects has .NET Framework version which is not compatible with other. 您的一个项目具有.NET Framework版本,该版本与其他项目不兼容。

  • Check in project properties of both of them the version of the framework. 检入两个版本的框架的项目属性。
  • Make them the same 使它们相同
  • Recompile both of them 重新编译它们

and most probably the trouble will gone. 而且很可能麻烦会消失了。

Hope this helps. 希望这可以帮助。

确保要从项目A使用的类的名称空间包含在using指令的项目B的文件中:

using projA.ExampleNamespace;

I have the same problem. 我也有同样的问题。 When I first added the reference all worked fine. 当我第一次添加参考时,一切正常。 But some time later after a rebuild there were errors and the classes and namespaces of "project A" were not longer recognized. 但是在重建之后的一段时间后,出现了错误,并且不再识别“项目A”的类和名称空间。 Removing and re-adding the reference solved the problem immediately (without rebuiling or anything). 删除并重新添加引用即可立即解决该问题(无需重新编译即可)。 There were no errors in other code and all DLLs and EXEs were build correctly. 其他代码没有错误,所有DLL和EXE均正确构建。 Build Order and Build Dependency settings were also correct. 构建顺序和构建依赖项设置也正确。 Seems to be a strange bug in Visual Studio (I use 2013 Professional). 似乎是Visual Studio中的一个奇怪的错误(我使用2013 Professional)。

I also checked how the reference was set in csproj file. 我还检查了如何在csproj文件中设置引用。 The csproj file didn't change at all after removing and re-adding the reference. 删除并重新添加引用后,csproj文件完全没有更改。 Neither did the sln file. sln文件也没有。

Maybe it's some strange caching behavior. 也许这是一些奇怪的缓存行为。 But as I used "Rebuild All" which cleans up temporary files imho, this shouldn't happen. 但是当我使用“全部重建”来清理临时文件时,这种情况不会发生。 Even restarting VS or the PC didn't help. 即使重启VS或PC也无济于事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM