关于库文件的引用问题

鸣上悠 2014-02-08 03:45:24
今天在看别人的Sample,需要使用一个DLL文件,添加到引用的时候显示“请确保此文件可访问并且是一个有效的程序集或COM组件”,程序可以编译成功,把库文件放到编译好的EXE文件的文件夹里可以运行得到想要的结果,但是直接在VS上调试时就会报错啊。
...全文
144 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
鸣上悠 2014-02-11
  • 打赏
  • 举报
回复
引用 6 楼 BenBenBears 的回复:
如果不是C#写的dll需要外部引用(2楼写的方法)或者直接引用dll的源项目,直接引用dll会提示不是有效的程序集或者COM组件。
那个貌似是个运行环境,在系统的环境变量里面设了一下,还有生成平台改成对应的平台就解决了。。。
宝_爸 2014-02-10
  • 打赏
  • 举报
回复
怎么调用的,什么样的dll?
BenBenBears 2014-02-09
  • 打赏
  • 举报
回复
如果不是C#写的dll需要外部引用(2楼写的方法)或者直接引用dll的源项目,直接引用dll会提示不是有效的程序集或者COM组件。
dogll 2014-02-08
  • 打赏
  • 举报
回复
查下路径 最好别有中文 或是空格之类 再试下
鸣上悠 2014-02-08
  • 打赏
  • 举报
回复
引用 2 楼 liuchaolin 的回复:
using System.Runtime.InteropServices; 。。。。 const string path = @"AspriseOCR.dll";//设定dll的路径 [DllImport(path, EntryPoint = "OCR")] public static extern IntPtr OCR(string file, int type); [DllImport(path, EntryPoint = "OCRpart")] static extern IntPtr OCRpart(string file, int type, int startX, int startY, int width, int height); [DllImport(path, EntryPoint = "OCRBarCodes")] static extern IntPtr OCRBarCodes(string file, int type); [DllImport(path, EntryPoint = "OCRpartBarCodes")] static extern IntPtr OCRpartBarCodes(string file, int type, int startX, int startY, int width, int height); 直接在代码中引入
额 还是原来的问题
鸣上悠 2014-02-08
  • 打赏
  • 举报
回复
引用 1 楼 ouyang4683 的回复:
DLL没注册 运行--cmd--regsvr32 dll的绝对路径名(路径实例:c:/dll/xxx.dll)
这个我试过了 貌似不行
md5e 2014-02-08
  • 打赏
  • 举报
回复
using System.Runtime.InteropServices; 。。。。 const string path = @"AspriseOCR.dll";//设定dll的路径 [DllImport(path, EntryPoint = "OCR")] public static extern IntPtr OCR(string file, int type); [DllImport(path, EntryPoint = "OCRpart")] static extern IntPtr OCRpart(string file, int type, int startX, int startY, int width, int height); [DllImport(path, EntryPoint = "OCRBarCodes")] static extern IntPtr OCRBarCodes(string file, int type); [DllImport(path, EntryPoint = "OCRpartBarCodes")] static extern IntPtr OCRpartBarCodes(string file, int type, int startX, int startY, int width, int height); 直接在代码中引入
ouyang4683 2014-02-08
  • 打赏
  • 举报
回复
DLL没注册 运行--cmd--regsvr32 dll的绝对路径名(路径实例:c:/dll/xxx.dll)

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧