如何解决这个问题无法添加对C:/ ---- .dll的引用。 [英] how to solve this A reference to C:/---- .dll could not be added.

查看:81
本文介绍了如何解决这个问题无法添加对C:/ ---- .dll的引用。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何解决这个问题无法添加对---- .dll的引用。请确保该文件是可访问的,并且必须是有效的程序集或COM组件。我有.dll文件,但它无法添加到项目引用

解决方案

.NET程序集是DLL或EXE文件:区别仅在于后者有一个静态Main方法,而前者没有。但是DLL文件不一定是.NET程序集 - 它们起源于本机可执行文件的动态链接库,并且仍然存在(并且已经生成)。



错误消息通常意味着您尝试添加的文件不是.NET程序集,而是本机DLL。您不能将它们添加为参考;您需要做的是使用DLLImport访问文件中的方法: http: //msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx [ ^ ]


您提供的信息不足以为您提供解决方案。

但是,你可以下载一个名为 Dependency Walker 的工具[ ^ ]并分析您的DLL。

该工具将帮助您确定您拥有的动物类型。

how to solve this A reference to ---- .dll could not be added.please make sure that file is accessibly and that must be valid assembly or COM component. I got .dll files but it can't add to the project reference

解决方案

A .NET Assembly is either a DLL or an EXE file: the difference is solely that the later has a static Main method, and the former doesn't. But a DLL file is not necessarily a .NET assembly - they started life as Dynamic Link Libraries for native executables, and still exist (and are produced) as such.

The error message normally means that the file you are trying to add is not a .NET assembly, but a native DLL instead. You can't add them as a reference; what you need to do is use DLLImport to access the methods within the file: http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.dllimportattribute.aspx[^]


The information you provide is not enough to give you a solution.
However, you could download a tool called Dependency Walker[^] and analyze your DLL.
The tool will help you to determine what kind of animal you have got.


这篇关于如何解决这个问题无法添加对C:/ ---- .dll的引用。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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