943,563 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1252
  • C# RSS
Nov 30th, 2008
0

C# DLL

Expand Post »
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?
Similar Threads
Reputation Points: 17
Solved Threads: 0
Junior Poster
complete is offline Offline
147 posts
since Dec 2005
Nov 30th, 2008
0

Re: C# DLL

you would just need to add it as a reference in the project

what specific piece are you having trouble with?
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008
Dec 1st, 2008
0

Re: C# DLL

Another thing to do, after you've made a reference to the DLL or project, is to use the using statement to include the namespace included in that DLL file. It's not absolutely required, but it does simplify using methods and classes from the DLL, rather than having to type out the fully qualified name of the method/class.

As a handy tip, you can use object explorer to look through a DLL's functions to determine what you're wanting to use.
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003
Dec 1st, 2008
0

Re: C# DLL

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?

http://i67.photobucket.com/albums/h2...st_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:

http://i67.photobucket.com/albums/h2...no/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:

C# Syntax (Toggle Plain Text)
  1. namespace BladaFlabaDab
  2. {
  3.  
  4. public class NookieBookieDoopieDoo
  5. {
  6.  
  7. private static readonly string SomethingYouDoNotNeedToKnow = @"SLAMADAMNADDORK";
  8.  
  9. private NookieBookieDoopieDoo()
  10. {
  11. }
  12.  
  13.  
  14.  
  15. public static void Send(string to, string subject, string body)
  16. {
  17. .
  18. .
  19. .
  20. }
  21.  
  22. public static void Send(string to, string replyTo, string subject, string body)
  23. {
  24. .
  25. .
  26. .
  27. }
  28.  
  29. private static void InitializeClient()
  30. {
  31. .
  32. .
  33. .
  34. }
  35. }
  36. }
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?
Reputation Points: 17
Solved Threads: 0
Junior Poster
complete is offline Offline
147 posts
since Dec 2005
Dec 1st, 2008
0

Re: C# DLL

you need to call it like this since it is static

C# Syntax (Toggle Plain Text)
  1. ClassName.MethodName();
  2.  
  3. NookieBookieDoopieDoo.InitializeClient();
  4. NookieBookieDoopieDoo.Send("to", "replyTo", "subject", "body");
Reputation Points: 133
Solved Threads: 141
Veteran Poster
dickersonka is offline Offline
1,162 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Capturing contents of launching file
Next Thread in C# Forum Timeline: how to print "" in c#





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC