简体   繁体   中英

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

Does anyone know how I can do this?

Most probably, also it's hard to say , you have .NET Framework version conflict. One of your projects has .NET Framework version which is not compatible with other.

  • 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. 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. Build Order and Build Dependency settings were also correct. Seems to be a strange bug in Visual Studio (I use 2013 Professional).

I also checked how the reference was set in csproj file. The csproj file didn't change at all after removing and re-adding the reference. Neither did the sln file.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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