Geeks With Blogs
Rupreet's Weblog Looking deep inside under the hood

Recently in my project we migrated from VS2003 to VS2005.  The application I am working on is a smart client application so it has lot many Win Forms. After migration, when the solution was opened up in VS2005, we faced this strange problem. None of the Forms were opening in the designer mode. It was throwing exception (shown below)

 

One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.


Object reference not set to an instance of an object.

Hide    


at System.Resources.Tools.StronglyTypedResourceBuilder.DefineResourceFetchingProperty(String propertyName, String resourceName, ResourceData data, CodeTypeDeclaration srClass, Boolean internalClass, Boolean useStatic)
at System.Resources.Tools.StronglyTypedResourceBuilder.InternalCreate(Dictionary`2 resourceList, String baseName, String generatedCodeNamespace, String resourcesNamespace, CodeDomProvider codeProvider, Boolean internalClass, String[]& unmatchable)
at System.Resources.Tools.StronglyTypedResourceBuilder.Create(IDictionary resourceList, String baseName, String generatedCodeNamespace, String resourcesNamespace, CodeDomProvider codeProvider, Boolean internalClass, String[]& unmatchable)
at System.Resources.Tools.StronglyTypedResourceBuilder.Create(IDictionary resourceList, String baseName, String generatedCodeNamespace, CodeDomProvider codeProvider, Boolean internalClass, String[]& unmatchable)
at Microsoft.VisualStudio.Design.Serialization.ResXGlobalObject.BuildType()
at Microsoft.VisualStudio.Design.Serialization.ResXGlobalObject.GetObjectType()
at Microsoft.VisualStudio.Shell.Design.GlobalType.get_ObjectType()
at Microsoft.VisualStudio.Design.Serialization.ResXGlobalObject.get_Children()
at Microsoft.VisualStudio.Design.Serialization.ResXGlobalObjectProvider.CreateGlobalObjectsForItem(ProjectItem item, GlobalObjectCollection oldObjects, GlobalObjectCollection newObjects, ITypeResolutionService typeResolver)
at Microsoft.VisualStudio.Design.Serialization.ResXGlobalObjectProvider.CreateGlobalObjectsForItem(ProjectItem item, GlobalObjectCollection oldObjects, GlobalObjectCollection newObjects, ITypeResolutionService typeResolver)
at Microsoft.VisualStudio.Design.Serialization.ResXGlobalObjectProvider.CreateGlobalObjects(Project project)
at Microsoft.VisualStudio.Design.Serialization.ResXGlobalObjectProvider.GetGlobalObjectsCore(Project project, Type baseType)
at Microsoft.VisualStudio.Shell.Design.GlobalObjectProvider.GetGlobalObjects(Project project, Type baseType)
at Microsoft.VisualStudio.Shell.Design.GlobalObjectService.GetGlobalObjects(Type baseType)
at Microsoft.VisualStudio.Shell.Design.GlobalObjectService.GetGlobalObjects()
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetTypeFromGlobalObjects(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError)
at System.Resources.ResXDataNode.ResolveType(String typeName, ITypeResolutionService typeResolver)
at System.Resources.ResXDataNode.GenerateObjectFromDataNodeInfo(DataNodeInfo dataNodeInfo, ITypeResolutionService typeResolver)
at System.Resources.ResXDataNode.GetValue(ITypeResolutionService typeResolver)
at System.Resources.ResXResourceReader.ParseDataNode(XmlTextReader reader, Boolean isMetaData)
at System.Resources.ResXResourceReader.ParseXml(XmlTextReader reader)
at System.Resources.ResXResourceReader.EnsureResData()
at System.Resources.ResXResourceReader.GetMetadataEnumerator()
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 Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)

 

This was causing lot of problems as we were not able to view the form. It took me 2 days to finally get the cause and find a resolution for the same.

 

Cause:

The cause for this is that while migrating, the existing resource files didn’t get migrated properly (I still need to figure out if this resource migration problem was due to incomplete migration by VS.NET or was due to our ignorance of warnings/errors given by VS.NET while migrating). We have data in format like:

 

<data name="lblName" xml:space="preserve">

    <value>Rupreet</value>

<data>

 

Now, if the previous resource file has some blank values something like:

 

<data name="lblName" xml:space="preserve"></data>

 

This will be invalid in the new schema for resources files. The value can be empty but the schema should be maintained. So the valid data with blank value should be

 

<data name="lblName" xml:space="preserve">

    <value></value>

</data>

 

Resolution:

In the resource file property, you need to add “ResXFileCodeGenerator” in the “Custom Tool” property. When you press enter, this tool runs and create a YourResourceFileName.Designer.cs file. With this, your resource file will contain new schema. If you get an error “Object reference not set to an instance” then this means that your data is not in proper format and the designer file will not be created. You first need to fix your data with the correct schema as I mentioned above and try running the tool again. When it saves properly with the desinger class creates, it means your resource file is in correct format. Now try opening your Forms, it should work! J

 

Posted on Wednesday, December 14, 2005 6:36 PM .NET Framework , .NET Framework 2.0 | Back to top


Comments on this post: VS2005 Designer Issue - WinForms not opening after migrating

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
I have the same problem. I tried your solution. Unfortunately, it create the Form.Designer.cs file OK but it still does not show the form. I scanned the resx file and could not find any missing value tags. I did find some empty tags. For example: <data name="label4.Image" type="System.Resources.ResXNullRef, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value />
Is this my problem?

Left by SB on Dec 15, 2005 2:33 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
No, you can always have empty values. Try these things:
1. Change your data like: <data name="label4.Image" type="System.Resources.ResXNullRef, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" xml:space="preserve">
<value /> </data>
2. You can also test it by removing all the data from your resx file and compile the code. Then try opening your forms. If it works, then you can see which data is giving you problem.
3. Hope you are doing this on all your resx files. I mean, lets say you have one resx file for english and one for german, you need to do this for both.

Otherwise, you can email me @ rs_gujral AT Yahoo.com
Left by Rupreet Singh Gujral on Dec 15, 2005 2:51 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Rupreet,

I tried both of your suggestions. First I changed the assembly versions to 2.0.0.0 for all .Net assemblies referenced in all resX files. I recompiled and closed and reopened Visual Studio. This did not fix the problem. Next, I removed all data from the resX files and recompiled, closed and opened VS and I still have the problem. Any other suggestions?

Thanks for your help.

SB
Left by SB on Dec 15, 2005 4:42 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Can you confirm if your Form is an inherited Form or it contains any UserControl?
Left by Jay on Dec 15, 2005 5:37 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
It directly inheirits form System.Windows.Form but it contains user controls.
Left by SB on Dec 15, 2005 9:00 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
SB problem solved. Here is the link to the solution.
forums.microsoft.com/MSDN/ShowPost.aspx?PostID=171276&SiteID=1&mode=1 (add http)
Left by Rupreet Singh Gujral on Dec 16, 2005 9:26 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
I'm getting a similar error, except I've tried your suggestions and the SB post but to no avail.

The error I'm getting is as follows:

One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.

An error occurred while parsing EntityName. Line 2, position 85.
Hide

at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseEntityName()
at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32 curPos, Char quoteChar, NodeData attr)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.GeneratedAssemblyEntry.RealizeMoniker(String moniker)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.GeneratedAssemblyEntry.get_FileName()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_Assembly()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.GeneratedAssemblyEntry.get_Assembly()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, String description)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchGeneratedEntries(AssemblyName assemblyName, String typeName, Boolean ignoreTypeCase, Assembly& assembly)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType refType)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.GetType(ITypeResolutionService trs, String name, Dictionary`2 names)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.FillStatementTable(IDesignerSerializationManager manager, IDictionary table, Dictionary`2 names, CodeStatementCollection statements, String className)
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 Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)

I've also tried deleting all the resx files...

Any help is appreciated
Left by Chris Stefano on Jan 06, 2006 1:08 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Hi Chris,
I havn't faced this issue, so am just guessing the cause -
-do you have any code which involve xml and does that xml contain special characters - like "&" ? - This should be converted to "&amp;" (without quotes).
-Also can you tell me more about your application - does your forms contain UserControls and these controls are used in these forms?
Left by Rupreet Singh Gujral on Jan 06, 2006 1:52 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
No, that's whats made it so frustrating.

I've created a class which inherits from ListBox and used it on a form in the same project. When I try to design the form, it fails to load. If I remove (manually) me list control then the form designer loads fine.

If I make my list class inherit from UserControl I get the same issue.

I've tried deleting all the bin & obj dirs as well as all temp files etc... and reloaded VS2005.

Also, the toolbox is automatically populated with my list control so I can drag it onto the design surface, but as I drag it, I get the same error message. So it is certainly some kind of load failure to do with the control.

I created the control by hand (i.e. not designed) so there is no resource files attached to it...
Left by Chris Stefano on Jan 06, 2006 3:04 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Hmm...I haven't faced this issue, but surely will love to debug it. Is it possible for you to send the control and dummy application where you used and its failing. Without going deep into the control, its hard to tell whats its cause.

If you can, then email me at rs_gujral AT yahoo dot com
Left by Rupreet Singh Gujral on Jan 07, 2006 12:16 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
I've managed to solve the issue...

I'd created my project in a directory pathed as "My Documents\Visual Studio 2005\Projects\1. ProtoTypes\MyPrototype1".
It seems that the "1. " part of the path was causing the error!

On further examination, it seems that having the default project location in "My Documents" causes the project path to be too deep (more than 266 chars) so I moved my default project location to my D drive.

The "1. " problem was still there, so I've had to rename my dirs to exclude the "1. " part.

I also tried installing the Enterprise Library under "My Documents\Visual Studio 2005\Projects" and when opening the solution I got project not found errors.
Left by Chris Stefano on Jan 09, 2006 10:10 AM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Oh, and there was an "&" in the pathing too. I think this is be the problem, not the "1. ".
I changed it to "+" and the designer works now. :-)))

Thanks for your help!
Left by Chris Stefano on Jan 09, 2006 10:35 AM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Is there something similar to ResXFileCodeGenerator for creating a Designer.cs file for the normal .cs file? Example: I have ConfigureOptics.cs which includes ConfigureOptics.resx. What I want is a ConfigureOptics.Designer.cs not one for the resource file.

Thanks in advance.

You can reach me at mta@qvii.com.
Left by Matt Arthur on Jan 25, 2006 7:50 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
I don't think so because when you use RegXFileCodeGenerator, it'll use the designer file. If you really want a designer file which is nothing but a simple partial class of the main cs file - you can manually create another file and use it as partial class. Other way is don't use RegXFileCodeGenerator which will use your designer.cs file for its stronly typed resource work - which i think won't be the right choice if you are working with strongly typed resources.
Left by Rupreet Singh Gujral on Jan 27, 2006 6:39 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
I was looking for a command or tool that would convert it to a partial class for me. I really don't want to modify over 40 forms and user controls by hand. Thanks for the feedback Rupreet.
Left by Matt A. on Jan 30, 2006 4:51 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Brilliant - a few hours of headscratching, then a hit on this in Google and away we went!

Perhaps this could be built into VS2005 as a rule it should check for???!!!
Left by Michael Dye on Feb 06, 2006 6:19 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Thank you -- that helped. This is exactly I was looking for...
Left by Hari on May 03, 2006 7:22 AM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Oh my thanks! I had something similar, and it was due to reorganizing my project folders, where one folder name contained an ampersand. Sheesh.
Left by Jeff Farnsworth on Aug 16, 2006 4:44 AM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Ok, thank you. I have a similar problem with inherits user controls. I imported a 2003 C# project. I use a base class inherit from UserControl and it runs fine in design mode(with ResXFileCodeGenerator). I use another class inherit form base class and it doesn't run in design mode (Object reference not set to an instance of an object). Is possible to use the same resolution for inherit classes?
Left by Toni C on Mar 28, 2007 2:38 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
I had this exact problem too, and the root cause was a folder in the project path that had an ampersand in it.

Many thanks for the solution!!! Saved many hours for me...
Left by Dan Bishop on Nov 10, 2007 9:08 AM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
====================
Hi,

am facing WSOD problem:
when am trying to open disgner view for a form which is inheriting BaseViewForm getting

white screen with this message:

One or more errors encountered while loading the designer. The errors are listed below.

Some errors can be fixed by rebuilding your project, while others may require code changes.

Could not load file or assembly 'Wrappers.CLI, Version=0.0.0.0, Culture=neutral,

PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Hide

at MYnamespace.BaseViewForm..ctor()
in C# project I added a reference to Wrappers.CLI.
Wrappers.CLI version is 1.0.0.1 but when I added reference to this the VS shows the version

as 0.0.0.0 (By looking at properties after adding reference)

Thanks,
Ramki
Left by Ramki on Apr 19, 2008 6:30 AM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Dear Sir,

I have a problem.I can't open my winforms in vb.net.An error occurred while parsing EntityName. Line 2, position 66 this tipe of problem.so plz as soon as posible send a mail.which is solve my problem.

Thank You.


Chandrajit
Left by Chandrajit Sarkar on Sep 24, 2008 12:12 AM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
I created a new website, and added a new web form. The designer window is not opening. No errors displayed. Sometimes in the "source view" the del and backspace key not works. Can you kindly suggest the idea to solve th issue.

Thanks in advance.
Left by Kumaresh on Feb 03, 2009 11:05 PM

# re: VS2005/VS2008 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Thank you for giving pointers.

Just in case, somebody still encounters this problem, I solved the problem by moving by project from a deep directory structure to a less-lengthy directory structure.

HTH
Left by Ousama on Jun 30, 2010 4:03 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
i tried all the above steps but it is not working..my from design is shown now but the controls are not their can u plz help me..thanks
Left by Ashraf on Jun 20, 2011 11:05 AM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Hi All,

Its late but might be help for someone.

I had the same problem and I resolved this problem in the following way.

- my app was in 2.0, I converted it into 3.5 and was facing this issue.
- I saw in .resx file there is an additional node
<data name="info" type="System.Resources.ResXFileRef, System.Windows.Forms">
</data>
- I commented out it
- and now its running like woooooo...

happy coding.. :)
Left by Digvijay Verma on Oct 21, 2013 5:07 PM

# re: VS2005 Designer Issue - WinForms not opening after migrating
Requesting Gravatar...
Thanks Digvijay Verma!!!
(because my english is very poor, i write in spanish)
Gracias Digvijay Verma!!!
he resuelto el problema gracias a ti!, pero recomiendo que hagan una busqueda en toda la solucion con "System.Resources.ResXFileRef" y comenten como recomendó Digvijay Verma toda la fila de la <data ... > <\data>.
Left by Joel Tavarez on Mar 08, 2014 10:30 AM

Your comment:
 (will show your gravatar)


Copyright © Rupreet Singh Gujral | Powered by: GeeksWithBlogs.net