I get this error about 75% of the time I try to debug in Visual Studio 2005. I have reinstalled VS and applied the latest service pack with no relief. It never happens if I run without debugging, only when I try to debug. It happens with every project I create, it's not isolated to a single project or solution. Any help is greatly appreciated.
It’s always thrown on this line (or equivalent):
public
static void Main(string[] args){
Application.Run(new MainForm());}
System.ComponentModel.Win32Exception was unhandled
Message="Window class name is not valid."
Source="System.Windows.Forms"
ErrorCode=-2147467259
NativeErrorCode=0
StackTrace:
at System.Windows.Forms.NativeWindow.WindowClass.RegisterClass()
at System.Windows.Forms.NativeWindow.WindowClass.Create(String className, Int32 classStyle)
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.TreeView.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at JCARepository.MainForm.Main(String[] args) in C:\Documents and Settings\John\My Documents\JCA\Repository\new\MDIClient\Form1.cs:line 266
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Window class name is not valid.
Ray_bihpgh20
danilomunoz
Gamargia
I have started a microsoft support service for this issue. I directed the support person to this thread as well as many other i have found. he has looked them over and is trying to replicate this. i will post whatever he comes up with on this thread.
Joe
p.s. my earlier post was wrong: it it NOT just linked to the treeview control. i can get it to happen with a blank project and any control added.
Melissa H.
You are right about it being linked to the TreeView, i think. All of my projects that do NOT have a TreeView in them work fine. Any project with a TreeView has this intermittent problem that will not go away. it happens more than 50% of the time...
the comctl32.dll is 5.82.2900.2982 - seems fine.
do you have any more suggestions on this topic
Thanks,
Joe
Helmut Leitner
One other thing. I saw, either in this thread or another about the same problem, that someone had found if they comment out the Application.EnableVisualStyles(); line, the problem went away. This works for me also:
//Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
I sent this to the tech support working on the problem; hopefully it helps them. In the mean time, that is what i am doing during debugging...
Eirian
LynnOoi
Nate00
I am getting the same thing in the C# Winforms designer.
Let me just say that I think the VS2005 designer is a disaster. If it works at runtime, it should work at design time, I shouldn't have to spend time writing code to make the IDE work. I did report this as a bug, and was told it's a 'feature'. No, it's not. It's stupid.
I need to deliver this tomorrow, and instead of writing code, I am fighting the IDE.
ShadowRayz
I am having the same problem. I even created a brand new project with nothing in it and can't run it now.
If I try to run it over and over again, eventually it will run.
Really frustrating.
jongas
Here's another stack from a different project, same problem:
System.ComponentModel.Win32Exception was unhandled
Message="Window class name is not valid."
Source="System.Windows.Forms"
ErrorCode=-2147467259
NativeErrorCode=0
StackTrace:
at System.Windows.Forms.NativeWindow.WindowClass.RegisterClass()
at System.Windows.Forms.NativeWindow.WindowClass.Create(String className, Int32 classStyle)
at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.TextBoxBase.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at ModuleLoader.Program.Main() in C:\Documents and Settings\John\My Documents\JCA\Repository\JcaRepositoryService\ModuleLoader\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
rgsjr
av_ster
creaturita
still working with the support.
i have not been able to reproduce the error in safe mode or safe mode with networking. has anyone else
JSantos196912