简体   繁体   English

在c#项目中添加引用......但它“消失了”?

[英]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. 我有这个c#项目...我将这个引用(一个dll)添加到它,并尝试在我的代码中使用该库。

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. 我建立这个的那一刻,它说它找不到ThePackage ,它就像那个使用,或者引用不存在。 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? 这可能是因为它迟到了,但老实说完全失去了为什么C#(2008)对我这样做?

DLL was built in 2008 to... maybe im missing some build option with the dll? DLL建于2008年......也许我错过了一些dll的构建选项?

I had same problem. 我有同样的问题。 You need to change target framework of your project from ".Net Framework 4 Client Profile" to ".Net Framework 4" 您需要将项目的目标框架从“.Net Framework 4 Client Profile”更改为“.Net Framework 4”

It worked for me. 它对我有用。

Check that the dll and the assembly run on the same CPU type (x86-x64). 检查dll和程序集是否在相同的CPU类型(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. 如果dll使用比应用程序更高的.net框架版本,你会看到这个。 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. 这可能不太可能我阅读你在评论中所说的内容,因为该应用程序是在visual studio 2010中,而dll是使用visual studio 2008构建的。但是,并不完全确定是这样的,因为问题引用了visual studio 2008.无论如何,检查您在引用项目中使用与引用项目相同的框架版本或更高版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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