C# Dll Messagebox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arggg
    New Member
    • Mar 2008
    • 91

    C# Dll Messagebox

    I have created a .dll that I am using in my .exe project however I would like to display information in the .dll in a messagebox from the dll. I did the [DllImport("user 32.dll")] and it still will not show the messagebox. Basically I need this for debugging the dll file to see what information it is getting/sending. Is it possible for .dll's to show messagebox's? Any ideas?
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    System.Windows. Forms.MessageBo x did not work?

    Comment

    • arggg
      New Member
      • Mar 2008
      • 91

      #3
      Originally posted by Plater
      System.Windows. Forms.MessageBo x did not work?
      Cant use System.Windows. Forms in a library.

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        Actually, you very much can.

        See, there are certain references automatically added to certain project types. Forms apps get System, System.Data, System.Deployme nt, System.Drawing, System.Windows. Forms, and System.Xml automatically. So you can put using System.Windows. Forms at the top and not have to type it out all the time.

        But just putting the using statement isn't the same as adding a reference. If you right-click the references folder, and click Add Reference, it will pop up a dialog where you can scroll down and select System.Windows. Forms. Then you can use all the objects in that namespace, including a messagebox.

        I have tested this with a class library (dll) referenced in a console app, and I did get a messagebox popup.

        Comment

        • arggg
          New Member
          • Mar 2008
          • 91

          #5
          Originally posted by insertAlias
          Actually, you very much can.

          See, there are certain references automatically added to certain project types. Forms apps get System, System.Data, System.Deployme nt, System.Drawing, System.Windows. Forms, and System.Xml automatically. So you can put using System.Windows. Forms at the top and not have to type it out all the time.

          But just putting the using statement isn't the same as adding a reference. If you right-click the references folder, and click Add Reference, it will pop up a dialog where you can scroll down and select System.Windows. Forms. Then you can use all the objects in that namespace, including a messagebox.

          I have tested this with a class library (dll) referenced in a console app, and I did get a messagebox popup.

          AHHH I was not adding it as a reference. That did the trick! Thanks a bunch!!

          Comment

          • joedeene
            Contributor
            • Jul 2008
            • 579

            #6
            hey, dont worry, haha, we've all been there once, haha take a look at this link just to look on how to add and remove and as insertalias said, references are automatically added to certain types of projects...
            Adding-Removing References

            joedeene

            Comment

            Working...