I am currently trying to get deeper into the .NET framework. I ran across an error while I was wondering if I could create two CommandManagers:
Cannot create an instance of CommandManager because it has no public constructors.
Obviously it means: don't do it, and it might not even make sense to have two of them. Now I came across an other error before with the message:
Cannot create an instance of ... because it is sealed
The effect is the same in prohibiting but what is the difference. Why does one choose a class to have no public constructors vs making it sealed?
EDIT:
Sorry I was ill for a couple of days. Further I mixed two languages: VB and C#. I had two tabs open and overlooked that one was standing on C# and one on VB Code. One class was sealed the other seemed to be NonInheritable. I didn't realize that this is actually the same. Now the error messages make sens.
IronPython Code snippet:
commandManager = CommandManager()
fails with
Cannot create instances of CommandManager because it has no public constructors
while
class MyCommandManager(CommandManager):
return super(MyCommandManager, self).__init__(*args, **kwargs)()
fails with:
cannot derive from System.Windows.Input.CommandManager because it is sealed
I was mislead by these errormessages and since my google and stackoverflow search returned no answer (naturally because CommandManager is always sealed in C# while always NonInheritable in VB) Further CommandManager seems to be both sealed and having no public constructor.