Codejoy
Codejoy

Reputation: 3816

Adding reference in c# project...but it "goes away"?

I have this c# project...i add this reference (a dll) to it, and try to use that library in my code.

I use what its called (its a database connector)

MiDB myDb;

it doesnt find that, i can right click and say "resolve" usings... that adds this line to the top:

using ThePackage.Database.AoNM.MiDB;

blah blah

So this works, it sees it, i can even then call a method that is seen:

myDb.InitDB("stuff here");

bingo. the minute I build this, it says it cannot find ThePackage, and its like that usings, or reference doesn't exists. In the solution explorer it is still there? I can remove the reference and add it again, and then this same thing happens, it "seems" like its there, but going to build and run it "goes away".

It might be cause its late, but I am honestly totally lost as to why C# (2008) is doing this to me?

DLL was built in 2008 to... maybe im missing some build option with the dll?

Upvotes: 3

Views: 1600

Answers (3)

Jack
Jack

Reputation: 167

I had same problem. You need to change target framework of your project from ".Net Framework 4 Client Profile" to ".Net Framework 4"

It worked for me.

Upvotes: 3

Dave Rael
Dave Rael

Reputation: 1759

if the dll is using a higher .net framework version than the application, you would see this. it's probably unlikely the way i read what you said in the comment in that the application is in visual studio 2010 and the dll was built with visual studio 2008. not completely sure that's the case, though, as the quesiton cites visual studio 2008. anyway, check that you are using the same framework version or greater in the referencing project as in the referenced.

Upvotes: 1

Haedrian
Haedrian

Reputation: 4328

Check that the dll and the assembly run on the same CPU type (x86-x64). I used to have similar errors (and very strange error messages) when they were different.

Upvotes: 3

Related Questions