问题
I have a C# console application with three assemblies: Main, Common and Utilities.
In a file in the Main assembly, Main.cs, I have the line:
using Utilities;
In a directory within the Common assembly, I have the DLL IBM.Data.DB2.dll.
In the Utilities assembly, I have a source module which accesses said dll.
Utilities have a Reference to IBM.Data.DB2.
In a source file within this assembly, Util.cs, I have the line:
using IBM.Data.DB2;
If, within a method in this file, I make any reference to code within the DB2 assembly, as in:
DbConnection c = new DB2Connection( _connectString );
I get an error compiling the Main assembly stating that the namespace name Utilities can not be found. Utilities compiles fine with or without the line. If I comment out the above line, everything compiles fine.
回答1:
A helpful colleague came by and solved this for me in about five seconds.
Turns out that by default, when a new Console app is created in VS 2010, it gets a target framework of ".NET Framework 4 Client Profile". Changing this to ".NET Framework 4" made the problem go away.
回答2:
Been dealing with a similar issue in VS 2013. I checked the client profile build version, everything looked fine, and I finally realized that I needed to right-click on the References tab to add the projects I had included to my solution References. I did this, and everything clicked!
来源:https://stackoverflow.com/questions/3991361/referring-to-code-in-ibm-data-db2-makes-that-assembly-unavailable-to-the-rest-of