Skip to main content
GameDev.net gamedev.net
🔒 Locked

[.net] C# DLL

Started by athono Nov 30, 2008 at 9:43 PM 4 replies 1.5k views
Original Post
athono
athono
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?
vermilion_wizard
vermilion_wizard
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.)
athono
athono
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?
CadetUmfer
CadetUmfer
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().
Anthony Umfer
BCullis
BCullis
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
Hazard Pay :: FPS/RTS in SharpDX (gathering dust, retained for... historical purposes)
DeviantArt :: Because right-brain needs love too (also pretty neglected these days)
benryves
benryves
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.
[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.