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