Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Designer: Value does not fall within expected range
 

Designer: Value does not fall within expected range

How do I find what component is causing the error? The call stack is unhelpful:

at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.VisualStudio.NativeMethods.ThrowOnFailure(Int32 hr, Int32[] expectedHRFailure)
at Microsoft.VisualStudio.Shell.Design.Serialization.DesignerDocDataService.GetFileDocData(String fileName, FileAccess access, String createTemplate, Boolean addToHostList, Boolean nestedItem)
at Microsoft.VisualStudio.Shell.Design.Serialization.DesignerDocDataService.GetChildDocData(String name, FileAccess access, String createTemplate)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.GetResourceDocData(CultureInfo info, FileAccess access)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.System.ComponentModel.Design.IResourceService.GetResourceReader(CultureInfo info)
at System.ComponentModel.Design.Serialization.ResourceCodeDomSerializer.SerializationResourceManager.GetMetadata()
at System.ComponentModel.Design.Serialization.ResourceCodeDomSerializer.SerializationResourceManager.GetMetadataEnumerator()
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializePropertiesFromResources(IDesignerSerializationManager manager, Object value, Attribute[] filter)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)

I was changing code in subroutines of Form1.vb, not working with the designer or with the properties box of components on the designer. I have looked through Form1.Designer.vb, and don't see anything obvious. But there are 1964 lines of code in the designer. It would be nice to have an error that tells me what values it finds objectionable. I do have a split container, but there are no minsize statements. I do have a four-day old backup since this is not the first time components have disappeared, but I will have to compare the codes to find all the fixes that I made (things like holding some values in My.Settings so they don't have to be re-entered when the program is run again). And it would be nice to be able to figure out what not to do when I re-design the form.

If I ignore the error and continue, all components disappear, and the form reverts to the initial design time properties.

And while I am at it, why is it that if I hide the tool bar at runtime and then show it, it re-appears above the menu strip instead of below it?

Thanks.
kwilson962a  Friday, May 23, 2008 12:56 PM

Try building the project, then go to the error stack and look for errors/warnings in the designer.

If this doesn't help and you still need to backup your 4-days-old code, i recommend using a software like "FreeDIFF" which accurately compares files for differences...

good luck

Nissim Trabelsy  Friday, May 23, 2008 2:55 PM

Try building the project, then go to the error stack and look for errors/warnings in the designer.

If this doesn't help and you still need to backup your 4-days-old code, i recommend using a software like "FreeDIFF" which accurately compares files for differences...

good luck

Nissim Trabelsy  Friday, May 23, 2008 2:55 PM
I should mention that I'm using Visual Basic Express 2008. The Error List window lists the error as a warning, with the File value blank, and both the line and column values listed as 0.

Thanks.
kwilson962a  Friday, May 23, 2008 5:04 PM
The project build fine, and runs fine. I just can't make any changes in the design window anymore, because I can't see anything. There are no errors other than the one unhelpful warning. I will look for the program that lists file differences, so I can try this again. And I think I should back things up more often. You would have thought I would have learned my lesson, with all of the lost data I've encountered over the years starting with Radio Shack's Model III computer (which I still have and which still works).

Thanks.
kwilson962a  Friday, May 23, 2008 5:13 PM
I was able to use FreeDiff to easily spot the updates in my code, and to make the changes to the backup of my project (after I backed up the backup, of course). The program runs fine, and the designer window is visible again. It only took about three hours total to make all the changes I wanted. Many thanks for the tip!

Keith

All those who believe in telekinesis, raise my hand.
kwilson962a  Saturday, May 24, 2008 11:25 PM

Did you ever find out what caused the error? I am having exactly the same problem in a UserControl. In fact I have 2 UserControls in the same project that are almost identical. One displays, one does not. I have not been able to determine what caused one to display and one to no.

Carroll Barrett  Friday, April 10, 2009 5:47 PM
I got the same error, and the error description in the Error List is really useless:

Value does not fall within the expected range.        Line: 0  Column: 0  

Does anyone know how to disable the form validation in the Designer? I guess we rather shouldn't do this in order to get rid of all errors before displaying the form UI. But when you get errors like these, and the code compiles&runs perfectly, then you can't see any of the UI elements in your form by using Designer and have to use lot of time to really find out where the "error" is.

Edit:
I found following exception in the Call Stack:

at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.VisualStudio.NativeMethods.ThrowOnFailure(Int32 hr, Int32[] expectedHRFailure)
at Microsoft.VisualStudio.Shell.Design.Serialization.DesignerDocDataService.GetFileDocData(String fileName, FileAccess access, String createTemplate, Boolean addToHostList, Boolean nestedItem)
at Microsoft.VisualStudio.Shell.Design.Serialization.DesignerDocDataService.GetFileDocData(String fileName, FileAccess access, String createTemplate)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomProvider.OnParseBegin(TextReader reader)
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) 

Ismar Slomic  Sunday, April 12, 2009 3:11 PM
I just wanted to bump this back up, since I am having a problem identical to Ismar. The program compiles and runs without a problem, producing a single warning, "Value does not fall within the expected range", no file name, line 0, column 0.

Loading the designer gives the same error as the folks before me posted and the top-level call in the call stack is identical to what Ismar posted. All I want to do is add another control to the form and it would be ridiculous to have to do it in code.
BobTPawn  Wednesday, June 10, 2009 10:42 PM
I had seen the same issue.
Build and Run successful but when viewed as Design, the error appeared.
I closed solution and restart IDE to resolve this problem.
khoaht  Thursday, July 02, 2009 4:05 AM

You can use google to search for other answers

Custom Search

More Threads

• custom button text problem
• How I can draw line between two user control?
• How do you disable the Up/Down arrow in PropertyGrid collection editor
• controls not rendering on the form
• manual position of Form2 from Form1
• Disable crtl and drag operation in designer host
• Hi ! Please Help on Combo Box as soon as possible.
• How to set maxlength of a column of a datagridview in C#.Net?
• currencyformat in textbox winforms
• Can categories in propertygrid comes as expanded...?