Bob Kaufman Bob Kaufman - 1 month ago 7
C# Question

Referring to Code in IBM.Data.DB2 makes that Assembly Unavailable to the rest of my Solution

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.

Answer

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.

Comments