Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DLL Problem

DLL Problem

Scheduled Pinned Locked Moved C#
helpquestion
10 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Expert Coming
    wrote on last edited by
    #1

    using System; namespace MyClassNameDLL { /// /// Summary description for Class1. /// public class MyClassName { public MyClassName() { // // TODO: Add constructor logic here // } public Hi() { szPassed = "Hi."; } } } MyClassName works as far as debugging, but Hi doesn't it says: Class, struc, or interface must have a return type What does that mean? -- modified at 20:06 Friday 10th February, 2006

    D 1 Reply Last reply
    0
    • E Expert Coming

      using System; namespace MyClassNameDLL { /// /// Summary description for Class1. /// public class MyClassName { public MyClassName() { // // TODO: Add constructor logic here // } public Hi() { szPassed = "Hi."; } } } MyClassName works as far as debugging, but Hi doesn't it says: Class, struc, or interface must have a return type What does that mean? -- modified at 20:06 Friday 10th February, 2006

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Your public Hi() is what it's complaining about. You haven't specified what the return type is, even if it's not supposed to have one (void).

      using System;
       
      namespace MyClassNameDLL
      {
      ///
      /// Summary description for Class1.
      ///
      public class MyClassName
      {
      public MyClassName()
      {
      //
      // TODO: Add constructor logic here
      //
      }
       
      public void Hi()
      {
      string szPassed = "Hi.";
      }
      }
      }

      RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      E 1 Reply Last reply
      0
      • D Dave Kreskowiak

        Your public Hi() is what it's complaining about. You haven't specified what the return type is, even if it's not supposed to have one (void).

        using System;
         
        namespace MyClassNameDLL
        {
        ///
        /// Summary description for Class1.
        ///
        public class MyClassName
        {
        public MyClassName()
        {
        //
        // TODO: Add constructor logic here
        //
        }
         
        public void Hi()
        {
        string szPassed = "Hi.";
        }
        }
        }

        RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        E Offline
        E Offline
        Expert Coming
        wrote on last edited by
        #3

        Ok, so I have a reference to the DLL file. How do I do the using statement? Right now it is: using MyClassNameDLL; What else do I need?

        D K 2 Replies Last reply
        0
        • E Expert Coming

          Ok, so I have a reference to the DLL file. How do I do the using statement? Right now it is: using MyClassNameDLL; What else do I need?

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Add a Reference to the MyClassNameDLL PROJECT, not the .DLL file. Since you're still developing the .DLL, it'll make changes easier when you recompile the app that's using this DLL. Right-click the References folder, pick Add Reference. Click the Projects tab, then highlight your .DLL project (I'm assuming both projects are in the same solution!), then click OK. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          1 Reply Last reply
          0
          • E Expert Coming

            Ok, so I have a reference to the DLL file. How do I do the using statement? Right now it is: using MyClassNameDLL; What else do I need?

            K Offline
            K Offline
            kourvoisier
            wrote on last edited by
            #5

            If your using Visual Studio be sure to add a reference to it By right clicking the name of your project and selecting add reference in the solution explorer. Browse to your .dll and select it. if you have: using MYClassNameDLL; at the very top of your code You are now ready to use your .dll in your code. Hope this helps

            E 1 Reply Last reply
            0
            • K kourvoisier

              If your using Visual Studio be sure to add a reference to it By right clicking the name of your project and selecting add reference in the solution explorer. Browse to your .dll and select it. if you have: using MYClassNameDLL; at the very top of your code You are now ready to use your .dll in your code. Hope this helps

              E Offline
              E Offline
              Expert Coming
              wrote on last edited by
              #6

              When I want to use a function within the DLL how do I use it? Usually I do: Hi();

              D 1 Reply Last reply
              0
              • E Expert Coming

                When I want to use a function within the DLL how do I use it? Usually I do: Hi();

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                It's looking like you REALLY need to pick up a book on C#. The questions you've asked in this thread are all beginning concepts in programming, let alone C#. GENERALLY, since you've imported the namespace your class sits in (the using statement at the top of the code), you can just create an instance of your class and call its Hi method:

                MyClassName myClass = new MyClassName();
                myClass.Hi();

                RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                E 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  It's looking like you REALLY need to pick up a book on C#. The questions you've asked in this thread are all beginning concepts in programming, let alone C#. GENERALLY, since you've imported the namespace your class sits in (the using statement at the top of the code), you can just create an instance of your class and call its Hi method:

                  MyClassName myClass = new MyClassName();
                  myClass.Hi();

                  RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                  E Offline
                  E Offline
                  Expert Coming
                  wrote on last edited by
                  #8

                  Two things: 1st: Although I don't take offense to you saying I don't know how to code, I have to say you are wrong. I do my time in coding with ASP.NET applications in which my employer require the code sit in a single .cs file. They don't want seperate .dlls or any other file except for files such as pictures. I am creating this program on my own to help me with a game I play. 2nd: I am having no problem getting to the functions on the DLL, I have done what you stated above, but usually when you use a DLL you don't end up having to do things like MyClass.MyFunctions. Thanks for the help.

                  D 1 Reply Last reply
                  0
                  • E Expert Coming

                    Two things: 1st: Although I don't take offense to you saying I don't know how to code, I have to say you are wrong. I do my time in coding with ASP.NET applications in which my employer require the code sit in a single .cs file. They don't want seperate .dlls or any other file except for files such as pictures. I am creating this program on my own to help me with a game I play. 2nd: I am having no problem getting to the functions on the DLL, I have done what you stated above, but usually when you use a DLL you don't end up having to do things like MyClass.MyFunctions. Thanks for the help.

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    ExpertComing wrote:

                    I am having no problem getting to the functions on the DLL, I have done what you stated above, but usually when you use a DLL you don't end up having to do things like MyClass.MyFunctions.

                    You're thinking of the time when these were actually called "functions". In an OOP model, they're called "methods". There are different access levels for methods. The example I showed you is one where an instance of the host class must be created before you can call the method on that instance. Static methods don't require and instace, but you stil have to specify the class that is hosting them. You can either directly specify the host class, like MyClassName.Hi();, or, if you change the using statement to using MYClassNameDLL.MyClassName;, you can shorten the method call to Hi();. While it's easier to type, it leaves the source of the method a bit vague and makes your code harder to read.

                    ExpertComing wrote:

                    Although I don't take offense to you saying I don't know how to code, I have to say you are wrong. I do my time in coding with ASP.NET applications

                    In what language? ASP.NET is just a web page generation technology. The concepts you're refering to are still very basic, Beginning C# - Week #1, concepts. I don't see how you could possible write an ASP.NET app in C# without knowing the things you're asking about already. I'm not here to insult you or ridicule your abilities. I'm just give you some advice based on the skill level of your question. If you are just starting out in C#, then you're best, fastest, method of learning this stuff is going to be a book. You'll get these questions answered far faster in those pages that you could in any forum. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                    E 1 Reply Last reply
                    0
                    • D Dave Kreskowiak

                      ExpertComing wrote:

                      I am having no problem getting to the functions on the DLL, I have done what you stated above, but usually when you use a DLL you don't end up having to do things like MyClass.MyFunctions.

                      You're thinking of the time when these were actually called "functions". In an OOP model, they're called "methods". There are different access levels for methods. The example I showed you is one where an instance of the host class must be created before you can call the method on that instance. Static methods don't require and instace, but you stil have to specify the class that is hosting them. You can either directly specify the host class, like MyClassName.Hi();, or, if you change the using statement to using MYClassNameDLL.MyClassName;, you can shorten the method call to Hi();. While it's easier to type, it leaves the source of the method a bit vague and makes your code harder to read.

                      ExpertComing wrote:

                      Although I don't take offense to you saying I don't know how to code, I have to say you are wrong. I do my time in coding with ASP.NET applications

                      In what language? ASP.NET is just a web page generation technology. The concepts you're refering to are still very basic, Beginning C# - Week #1, concepts. I don't see how you could possible write an ASP.NET app in C# without knowing the things you're asking about already. I'm not here to insult you or ridicule your abilities. I'm just give you some advice based on the skill level of your question. If you are just starting out in C#, then you're best, fastest, method of learning this stuff is going to be a book. You'll get these questions answered far faster in those pages that you could in any forum. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

                      E Offline
                      E Offline
                      Expert Coming
                      wrote on last edited by
                      #10

                      Well, I would always have all my code in one class, it becomes a slight mess, but it was easy. I have 3 books, I'll read them, thanks for the help, and the advice. I was used to Visual Basic 5, before .NET. You are right about the functions verse methods thing, thanks.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups