2
votes

In Visual Studio Enterprise 2017 when I create a Windows Form in my solution I get the following error page right away (instead of the designer page):

The stack trace is:

at Microsoft.VisualStudio.LanguageServices.CSharp.CodeModel.CSharpCodeModelService.GetTypeSymbolFromFullName(String fullName, Compilation compilation)
at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.RootCodeModel.DotNetNameFromLanguageSpecific(String languageName)
at EnvDTE80.CodeModel2.DotNetNameFromLanguageSpecific(String LanguageName)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.CodeTypeDeclarationFromCodeClass(CodeClass vsClass)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.OnNamespacePopulateTypes(Object sender, EventArgs e)
at System.CodeDom.CodeNamespace.get_Types()
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomParser.Parse(TextReader codeStream)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.MergedCodeDomParser.System.CodeDom.Compiler.ICodeParser.Parse(TextReader stream)
at System.CodeDom.Compiler.CodeDomProvider.Parse(TextReader codeStream)
at Microsoft.VisualStudio.Shell.Design.Serialization.CodeDom.CodeDomDocDataAdapter.get_CompileUnit()
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)

The provided links on the page do not help since they only link to generic documentation/help pages. How can this error be fixed?

3
Does this exception occur if you copy and paste an existing form? - mjwills
@mjwills: Similar, see my answer below. - BullyWiiPlaza

3 Answers

4
votes

It turns out the folder was named Form and that clashed with the Microsoft Form class. Renaming the inherited class from Form to System.Windows.Forms.Form twice in total fixes the issue. Still a bug that should be handled automatically like this by Visual Studio.

0
votes

Different Problem same Error Message SOLVED ... "Value does not fall within the expected range" and designer not displaying my form.

SOLUTION: I had docked-to-Fill with a control to my main form, and it worked fine. But then I started getting the error, and the "designer" no longer displayed. I recently added a control from the Tool dialog with a double-click, instead of drag-and-drop ... that was the culprit. To fix it, I commented the line (in the myFormMain.Designer.cs) that docked the control to the main form. And yes, the designer view worked again and I could find and delete the control I added from the Tools dialog with a double-click.

0
votes

I got this in Visual Studio 2019 in a Windows Forms app. I'd been working on it for a few days, opening and closing the solution with no issue. I applied a VS upgrade and when I went to open the app, I got this error message.

When nothing else worked, I unloaded and reloaded the project from the solution, and that fixed it.

I hope it's as simple as that for you.