Jump to content
  • Advertisement
Sign in to follow this  
athono

[.net] C# DLL

This topic is 3609 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Create a new project, right click "References", click "Add Reference" and then the Browse tab will let you browse to the dll file. This will reference the dll file, I assume you don't mean that you really want the source code for the dll inside the application that you're writing. (If so, it's just a matter of copy-paste.)

Share this post


Link to post
Share on other sites
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?

first_problem.jpg

Strangely, "Equals", "GetHashCode", "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:

objects.jpg

So now to look closer at the DLL source code.Could there be a problem in the fact that the constructor ( private NookieBookieDoopieDoo() ) is
defined as a privvate? Could there be a problem that the methods are static?

It looks something like this:


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()
{
.
.
.
}
}
}

Could there be a problem in the fact that the constructor ( private NookieBookieDoopieDoo() ) is
defined as a privvate? Could there be a problem that the methods are static?

Share this post


Link to post
Share on other sites
Kinda limited info to go on, but it looks like you're referencing the assembly fine. From the code you showed, looks like a static class. As such, you should access the functionality like NookieBookieDoopieDoo.Send(), rather than NookieBookieDoopieDoo thing; thing.Send().

Share this post


Link to post
Share on other sites
Having run into similar problems recently, might I suggest the following change?


...
ClassInDLL thing = new ClassInDLL();

thing.method(); //intellisense should now pick up the methods

Share this post


Link to post
Share on other sites
Quote:
Original post by athono
Strangely, "Equals", "GetHashCode", "GetType" and "ToString" are not seen in the DLL's source code for available methods for this class.
.NET classes are derived from System.Object.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!