简体   繁体   中英

Using unknown dll in a c# project

I have got a dll from another program on my computer. According to its name it could have the functionality that I need for my own c# project. It seems to be also made with 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. If it is a native DLL then you'd need to do some reverse engineering.

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).

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
Borrowed from this msdn blog

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 .

You can just reference the dll you want in your project and use Object Browser to see what Methods etc you can access.

Step 1: Add reference

在此处输入图片说明

Step 2: Choose dll

在此处输入图片说明

Step 3: View in Object Browser

在此处输入图片说明

Step 4: Browse Library

在此处输入图片说明

Step 5: Find what you need

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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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