Go Back   CodingForums.com > :: Computing & Sciences > Computer Programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-01-2008, 01:57 AM   PM User | #1
complete
New Coder

 
complete's Avatar
 
Join Date: Jul 2005
Location: USA
Posts: 81
Thanks: 2
Thanked 0 Times in 0 Posts
complete is an unknown quantity at this point
C# dll

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?
complete is offline   Reply With Quote
Old 12-01-2008, 02:05 AM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
You need to take the physical dll and add it under you're resources (so make sure you have a local copy).

I no longer have visual studio, but I recall there is an actual folder in you're navigation pane. Simply right click that or you're project and select to add a resource. If its not there, you can get to it under you're project properties as well, or under tools. There are a few places you can get to you're resources.

Testing is always a pain though, make sure you compile and run on local disks only or you may have problems with running it via networked drives (permission problems, it will deny you network access). This goes for any dll you resource into you're c# project.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 12-01-2008, 04:20 AM   PM User | #3
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,042
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
If you want to add it to a C# application, you just add the DLL as a reference under the project. In the solution explorer window it lets you do that. If you want to use that C# DLL in say a C++ program, it becomes more complicated because the C# DLL has to be compiled with COM support.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 12-02-2008, 12:56 AM   PM User | #4
complete
New Coder

 
complete's Avatar
 
Join Date: Jul 2005
Location: USA
Posts: 81
Thanks: 2
Thanked 0 Times in 0 Posts
complete is an unknown quantity at this point
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", "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:



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:

Code:
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?
complete is offline   Reply With Quote
Old 12-02-2008, 01:11 AM   PM User | #5
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,635
Thanks: 4
Thanked 2,448 Times in 2,417 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Private constructors are fine, and as long as you're static methods are public they are also fine. I see you're class is also public, which is good (I'm thinking that I recall visual studio having a problem with defining internal instead of public when it thinks it can get away with it).

Anyway, its you're usage thats wrong.
Code:
MyClass thing;
thing.*;
thing hasn't been assigned a value, and it cannot be constructed as a new type of MyClass. Insead, you want to use MyClass.* for you're methods.

Thing has those methods showing up since they are a part of object (equals, gettype, gethashcode and tostring). Thing doesn't exist as an actual object by this point, but it does exist as a MyClass in memory (which is why the auto complete provides you with values).

Edit:
Any reason as well why you would remove the text from you're classes? All that important information is listed there.
Oh, and don't forget the top tabs as well :P
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php

Last edited by Fou-Lu; 12-02-2008 at 01:15 AM..
Fou-Lu is offline   Reply With Quote
Old 12-02-2008, 06:28 AM   PM User | #6
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,042
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Quote:
Originally Posted by Fou-Lu View Post
Anyway, its you're usage thats wrong.
Code:
MyClass thing;
thing.*;
thing hasn't been assigned a value, and it cannot be constructed as a new type of MyClass. Insead, you want to use MyClass.* for you're methods.

Thing has those methods showing up since they are a part of object (equals, gettype, gethashcode and tostring). Thing doesn't exist as an actual object by this point, but it does exist as a MyClass in memory (which is why the auto complete provides you with values).
That is the exact source of the problem. When you instantiate the class like you are doing, it doesn't show the static methods. Do what Fou-Lu laid out and it will work.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:41 AM.


Advertisement
Log in to turn off these ads.