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?
C# dll
Collapse
X
-
Well, it wouldn't include the source code, but you can easily add a DLL to project. Just right-click the project, and click Add Reference. You can use the DLL's classes and objects by referencing them through their namespace. -
I have done a few things. I have created a console app to use as the front-end to the project. Then I have added the DLL as a reference like this:
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 code file(s) where you want to use the DLL.
I have also found that I can add the Project that the DLL was made in into my new Solution file.
I have included the namespace of the DLL in the "using" section of my code.
And the intelligent type I am using recognizes this class when I declare it in my code.
But it does not seem to recognize all the methods (api's) of the class.
What am I doing wrong?

Strangely, "Equals", "GetHashCod e", "GetType" and "ToString" are not seen in the DLL's source code for available methods for this class.
Also, I know that if you double click on the added reference, an Object Explorer should come up showing the available methods. This is not what happens:

So now to look closer at the DLL source code.Could there be a problem in the fact that the constructor ( private NookieBookieDoo pieDoo() ) is
defined as a privvate? Could there be a problem that the methods are static?
It looks something like this:
Could there be a problem in the fact that the constructor ( private NookieBookieDoo pieDoo() ) isCode:namespace BladaFlabaDab { public class NookieBookieDoopieDoo { private static readonly string SomethingYouDoNotNeedToKnow = @"SLAMADAMNADDORK"; private NookieBookieDoopieDoo() { } public static void Send(string to, string subject, string body) { . . . } public static void Send(string to, string replyTo, string subject, string body) { . . . } private static void InitializeClient() { . . . } } }
defined as a privvate? Could there be a problem that the methods are static?Comment
-
That could be the problem. Static methods and members aren't referenced through an instance, but through the class itself.
So say you have a class called something:
Here's how you would reference each:Code:public class Something { private string thing; public void Show() { Console.WriteLine(thing); } public static void ShowSomethingStatic() { Console.WriteLine("Show me something."); } }
Also, if you want to use the code in the constructor, you will need to declare it as public.Code:Something x = new Something(); //this is how you reference non-static methods x.Show(); //this is how you reference static methods Something.ShowSomethingStatic();
Also, the methods you mention that you didn't define are inherited from the base class: Object. Every class that you don't specifically define what it extends automatically extend Object. These methods belong to it. You can override them if you want.
Just to clarify, every class is derived from Object, if you trace the inheritance back up to the top.
These are fundamental concepts to Object-Oriented Programming, they are true for most OOP languages.Comment
Comment