无法在桌面VS2010中添加dll [英] Fail to Add dll in desktop VS2010

查看:111
本文介绍了无法在桌面VS2010中添加dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Web项目中使用.DLL作为参考,这是可以的,当我在Windows项目中使用相同的.dll文件作为参考时,在使用myDLLFile时会发生此错误;

找不到类型或名称空间名称"myDLLFile.dll"(您是否缺少using指令或程序集引用?)D:\ VS2010 \ SAP_GUI_DT \ SAP_GUI_DT \ Plant.cs

I use .DLL as refrence in web project it is OK, when I use the same .dll file as a refrence in windows project this error happened when I use using myDLLFile;

The type or namespace name "myDLLFile.dll" could not be found (are you missing a using directive or an assembly reference?) D:\VS2010\SAP_GUI_DT\SAP_GUI_DT\Plant.cs

推荐答案

检查此DLL是否与Windows窗体兼容(以及.Net框架版本是否兼容).
Check whether this DLL is compatible with windows forms (and also if the .Net framework version is compatible).


您说过使用"using myDLLFile;".那很可能是不正确的. using语句需要在DLL中定义的名称空间.要确认myDLLFile是正确的名称空间,请查看WinForm解决方案.如果您的WinForm解决方案(按您说的那样工作)也使用了
You said use "using myDLLFile;". That is most probably not correct. The using statement needs a name space that is defined in your DLL. To confirm that myDLLFile is the correct name space look into your WinForm solution. If your WinForm solution (that works as you said) also uses
...
using myDLLFile;
...


那么您的使用"语句就可以了,但是您仍然需要在解决方案视图的引用"下添加对该DLL的引用.

最好的问候,

曼弗雷德(Manfred)


then your "using" statement is OK, BUT you still need to add a reference to that DLL under "References" in the solution view.

Best Regards,

Manfred


到目前为止,您已经得到的答案已经足够好了,但让我们问:您是自己的myDLLFile.dll(还是您有源代码)?没有可访问的源代码的第3方?

这有很大的不同.如果您有源代码,请将其包含在相同的解决方案中,并使用项目引用"而不是对可执行文件的引用. (转到项目的解决方案资源管理器->参考->添加参考->项目选项卡.)与可执行文件参考(添加参考->浏览选项卡)相比,我将为您带来很多好处.
好处1:解决方案的项目依赖项是自动设置的;
好处2:如果升级myDLLFile.dll,您将不胜感激:版本信息的增加不会强制您重新设置此引用(它将用作可执行引用).
The answers you already have so far are good enough, but let''s ask: is myDLLFile.dll your own (or if you have a source code for it) or this is a 3-rd party with no accessible source code?

This makes great difference. If you have a source code, include it in the same solution and use "Project reference" instead of reference to executable. (Go to project''s Solution Explorer -> Reference -> Add Reference -> the tab Projects.) I will give you great benefits over executable reference (Add Reference -> the tab Browse).

Benefit #1: Solution''s project dependencies are set up automatically;
Benefit #2: you will greatly appreciate it if you upgrade your myDLLFile.dll: incremented version information will not force you to re-set this reference (it will for executable reference).


这篇关于无法在桌面VS2010中添加dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆