简体   繁体   中英

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?

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.

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.

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.

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