Exposing the methods of a DLL in C#
Asked Answered
L

6

5

After someone creates a DLL in C# using the Microsoft Visual development environment, how would another programmer take that code, make a new project that includes the DLL's source and make a GUI that uses the DLL'S API?

I have already done the following four steps:

1) In the Solution Explorer right-click "References" and select "Add Reference ...".

2) Select the "Browse" tab.

3) Navigate to the DLL and select it.

4) Add the appropriate "using" directive to the top of the code.

What is next? After I declare a new object, how do I see what methods to use?

Ligniform answered 16/3, 2009 at 22:31 Comment(0)
B
10

View Menu -> Object Browser

You should be able to look at the objects/methods and so on contained in the DLL and publicly exposed.

Bendite answered 16/3, 2009 at 22:33 Comment(0)
H
1

You should be able to use intellisense and the object explorer as always. Without the source that will be your best bet.

Helpful answered 16/3, 2009 at 22:32 Comment(0)
U
1

I don't have any code off the top of my head but have you investigated the Reflection library? You should be able to figure out and run everything you need with that...

Unclothe answered 16/3, 2009 at 22:34 Comment(0)
P
1

you can load the DLL via the .NET Reflector tool from red-gate and see all of the api and even how it was implemented http://www.red-gate.com/products/reflector/

Phuongphycology answered 16/3, 2009 at 22:37 Comment(0)
S
0

Well...

Suppose your library is called MyLib.DLL

You would do:

MyLib ml = new MyLib();
ml.YourMethodsShouldAppearHere(); //If they are public of course.

;)

Septavalent answered 16/3, 2009 at 22:33 Comment(0)
D
0

You can open any .NET DLL in this 3rd party tool called ".NET Reflector". This tool will allow you to view all the types/methods/properties and even decompile the code contained in the DLL.

.NET Reflector is similar to the object browser in Visual Studio, but is way more powerful.

If you haven't tried Reflector yet, I highly recommend it (it's really easy to use)!

Disburse answered 16/3, 2009 at 22:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.