简体   繁体   English

在AC#项目中使用未知的DLL

[英]Using unknown dll in a c# project

I have got a dll from another program on my computer. 我从计算机上的另一个程序获得了一个dll。 According to its name it could have the functionality that I need for my own c# project. 根据其名称,它可以具有我自己的c#项目所需的功能。 It seems to be also made with c#. 它似乎也是用c#制作的。

Is it possible to find out the functions in it and use them? 是否可以找出其中的功能并使用它们?

If it is a C# DLL then you can add a reference and use it. 如果它是C#DLL,则可以添加引用并使用它。 If it is a native DLL then you'd need to do some reverse engineering. 如果它是本机DLL,则需要进行一些反向工程。

However, what you are describing is not the normal way to do about developing software. 但是,您所描述的不是开发软件的常规方法。 To write decent software you need to have good documentation for the libraries that you use. 要编写像样的软件,您需要拥有有关所使用库的良好文档。 Trying to guess how a library is meant to be called is a recipe for disaster. 试图猜测如何调用一个库是灾难的秘诀。 Development should be based on a solid and deep understanding of the tools you are using. 开发应基于对所使用工具的深刻理解。

Visual Studio provides the Object Browser if you want insight about a DLL (for those written in .NET involving IL). 如果您想了解有关DLL的信息(对于使用.NET编写的涉及IL的信息),Visual Studio将提供对象浏览器

screenshot of object browser http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-65-29/4774.wmob04.jpg 对象浏览器的屏幕快照http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-65-29/4774.wmob04.jpg
Borrowed from this msdn blog 从此msdn博客借来的

However, if you need more control or want the ability to not only include the library but view the source (in most instances) and step through it (debugging), I suggest grabbing .NET Reflector . 但是,如果您需要更多控制权或者想要不仅包含库而且还可以查看源代码(在大多数情况下)并逐步进行调试(调试)的功能,建议使用.NET Reflector

You can just reference the dll you want in your project and use Object Browser to see what Methods etc you can access. 您可以只在项目中引用所需的dll ,然后使用Object Browser查看可以访问的方法等。

Step 1: Add reference 步骤1:添加参考

在此处输入图片说明

Step 2: Choose dll 步骤2:选择dll

在此处输入图片说明

Step 3: View in Object Browser 步骤3:在对象浏览器中查看

在此处输入图片说明

Step 4: Browse Library 步骤4:浏览资料库

在此处输入图片说明

Step 5: Find what you need 步骤5:找到您需要的

Happy Coding :) 快乐编码:)

Absolutely! 绝对! If you can add it as a reference by right-clicking your project references, clicking add reference, and then browsing to it, it should be compatible with the version of .NET that you are using. 如果您可以通过右键单击项目引用,单击“添加引用”,然后浏览到它来将其添加为引用,则它应该与您所使用的.NET版本兼容。 At that point, try to instantiate it and see if you can go to definition on the instantiation. 到那时,尝试实例化它,看看是否可以对实例化进行定义。 Crude but an effective way to get used to using external dlls. 粗略但习惯于使用外部dll的有效方法。

如果确实是C#DLL,则可以将其添加为对项目的引用,然后使用对象浏览器查看其包含的命名空间和类。

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

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