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. MessageBoxManager .dll using

MessageBoxManager .dll using

Scheduled Pinned Locked Moved C#
helpcsharpvisual-studiowinformsquestion
5 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.
  • O Offline
    O Offline
    ormonds
    wrote on last edited by
    #1

    I am new to C# (using VS 2017 CE) and have a Windows Forms App in which I would like to use MessageBoxManager. The .DLL is present and correct in my solution, showing under References in the same manner as another .DLL which works fine. I thought that I needed to add a "using MessageBoxManager" to my project, but when I do I get the error: CS0246 The type or namespace "MessageBoxManager" could not be found (are you missing a using directive or an assembly reference? If I remove the "using" line I get no error and the code runs fine, ignoring all lines such as:-

                MessageBoxManager.Yes = "Yes/Oo";
                MessageBoxManager.No = "No/Hindi";
                MessageBoxManager.Unregister();
    

    I suspect I am missing some elementary understanding, can anyone help me?

    P B 2 Replies Last reply
    0
    • O ormonds

      I am new to C# (using VS 2017 CE) and have a Windows Forms App in which I would like to use MessageBoxManager. The .DLL is present and correct in my solution, showing under References in the same manner as another .DLL which works fine. I thought that I needed to add a "using MessageBoxManager" to my project, but when I do I get the error: CS0246 The type or namespace "MessageBoxManager" could not be found (are you missing a using directive or an assembly reference? If I remove the "using" line I get no error and the code runs fine, ignoring all lines such as:-

                  MessageBoxManager.Yes = "Yes/Oo";
                  MessageBoxManager.No = "No/Hindi";
                  MessageBoxManager.Unregister();
      

      I suspect I am missing some elementary understanding, can anyone help me?

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      using MessageBoxManager; states that you expect that the namespace that your MessageBoxManager class is in has to be called MessageBoxManager. This cannot be the case because you cannot declare a class and namespace with the same name; .NET doesn't allow this. If you use the Object Browser View > Object Broswer, you should be able to search for MessageBoxManager. When you find it, it will tell you which namespace it is actually in. If you then look in your code, I suspect you'll find that you already have that using statement in place.

      This space for rent

      O B 2 Replies Last reply
      0
      • P Pete OHanlon

        using MessageBoxManager; states that you expect that the namespace that your MessageBoxManager class is in has to be called MessageBoxManager. This cannot be the case because you cannot declare a class and namespace with the same name; .NET doesn't allow this. If you use the Object Browser View > Object Broswer, you should be able to search for MessageBoxManager. When you find it, it will tell you which namespace it is actually in. If you then look in your code, I suspect you'll find that you already have that using statement in place.

        This space for rent

        O Offline
        O Offline
        ormonds
        wrote on last edited by
        #3

        That's it, thank you for your answer.

        1 Reply Last reply
        0
        • P Pete OHanlon

          using MessageBoxManager; states that you expect that the namespace that your MessageBoxManager class is in has to be called MessageBoxManager. This cannot be the case because you cannot declare a class and namespace with the same name; .NET doesn't allow this. If you use the Object Browser View > Object Broswer, you should be able to search for MessageBoxManager. When you find it, it will tell you which namespace it is actually in. If you then look in your code, I suspect you'll find that you already have that using statement in place.

          This space for rent

          B Offline
          B Offline
          BillWoodruff
          wrote on last edited by
          #4

          Pete O'Hanlon wrote:

          you cannot declare a class and namespace with the same name;

          I respectfully suggest this is a case where C# (VS 2017, 4.7.1, Debug, error check level #4) ... still ... lets you "get away with murder:" this will compile and run:

          namespace SomeClass // a Project added to a WinForm app
          {
          public class SomeClass
          {
          public int I { get; }
          public string S { get; }

              public SomeClass(int i, string s)
              {
                  I = i;
                  S = s;
              }
          }
          

          }

          // invoked in the WinForm app NameSpace;
          // using SomeClass;

          // sample call
          // SomeClass.SomeClass dc = new SomeClass.SomeClass(100,"ddd");

          The user is seeing an ambiguous reference exception because he has not dot-qualified his call. imho, the C# compiler should never allow this ! I;m surprised ReSharper doesn't red-line this. Happy New Year !

          «While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it.» Claude Levi-Strauss (Tristes Tropiques, 1955)

          1 Reply Last reply
          0
          • O ormonds

            I am new to C# (using VS 2017 CE) and have a Windows Forms App in which I would like to use MessageBoxManager. The .DLL is present and correct in my solution, showing under References in the same manner as another .DLL which works fine. I thought that I needed to add a "using MessageBoxManager" to my project, but when I do I get the error: CS0246 The type or namespace "MessageBoxManager" could not be found (are you missing a using directive or an assembly reference? If I remove the "using" line I get no error and the code runs fine, ignoring all lines such as:-

                        MessageBoxManager.Yes = "Yes/Oo";
                        MessageBoxManager.No = "No/Hindi";
                        MessageBoxManager.Unregister();
            

            I suspect I am missing some elementary understanding, can anyone help me?

            B Offline
            B Offline
            BillWoodruff
            wrote on last edited by
            #5

            See my explanation of why your code does not work in my response to Pete O'Hanlon on this thread. I think you may be surprised by what you learn. A NameSpace with a Class (or anything else) with the same name inside it is a bad practice that will cause problems.

            «While I complain of being able to see only a shadow of the past, I may be insensitive to reality as it is now, since I'm not at a stage of development where I'm capable of seeing it.» Claude Levi-Strauss (Tristes Tropiques, 1955)

            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