Rupreet's Weblog

Looking deep inside under the hood

  Home  |   Contact  |   Syndication    |   Login
  11 Posts | 0 Stories | 27 Comments | 59 Trackbacks

News

Archives

Post Categories

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

Feedback

# re: VS2005 Designer Issue - WinForms not opening after migrating 12/15/2005 2:33 PM SB
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?



# re: VS2005 Designer Issue - WinForms not opening after migrating 12/15/2005 2:51 PM Rupreet Singh Gujral
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


# re: VS2005 Designer Issue - WinForms not opening after migrating 12/15/2005 4:42 PM SB
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

# re: VS2005 Designer Issue - WinForms not opening after migrating 12/15/2005 5:37 PM Jay
Can you confirm if your Form is an inherited Form or it contains any UserControl?

# re: VS2005 Designer Issue - WinForms not opening after migrating 12/15/2005 9:00 PM SB
It directly inheirits form System.Windows.Form but it contains user controls.

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

# re: VS2005 Designer Issue - WinForms not opening after migrating 1/6/2006 1:08 PM Chris Stefano
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

# re: VS2005 Designer Issue - WinForms not opening after migrating 1/6/2006 1:52 PM Rupreet Singh Gujral
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?

# re: VS2005 Designer Issue - WinForms not opening after migrating 1/6/2006 3:04 PM Chris Stefano
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...

# re: VS2005 Designer Issue - WinForms not opening after migrating 1/7/2006 12:16 PM Rupreet Singh Gujral
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

# re: VS2005 Designer Issue - WinForms not opening after migrating 1/9/2006 10:10 AM Chris Stefano
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.


# re: VS2005 Designer Issue - WinForms not opening after migrating 1/9/2006 10:35 AM Chris Stefano
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!

# re: VS2005 Designer Issue - WinForms not opening after migrating 1/25/2006 7:50 PM Matt Arthur
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.

# re: VS2005 Designer Issue - WinForms not opening after migrating 1/27/2006 6:39 PM Rupreet Singh Gujral
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.

# re: VS2005 Designer Issue - WinForms not opening after migrating 1/30/2006 4:51 PM Matt A.
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.

# re: VS2005 Designer Issue - WinForms not opening after migrating 2/6/2006 6:19 PM Michael Dye
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???!!!

# re: VS2005 Designer Issue - WinForms not opening after migrating 5/3/2006 7:22 AM Hari
Thank you -- that helped. This is exactly I was looking for...

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


# re: VS2005 Designer Issue - WinForms not opening after migrating 3/28/2007 2:38 PM Toni C
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?

# re: VS2005 Designer Issue - WinForms not opening after migrating 11/10/2007 9:08 AM Dan Bishop
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...

# re: VS2005 Designer Issue - WinForms not opening after migrating 4/19/2008 6:30 AM Ramki
====================
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

# re: VS2005 Designer Issue - WinForms not opening after migrating 9/24/2008 12:12 AM Chandrajit Sarkar
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


# re: VS2005 Designer Issue - WinForms not opening after migrating 2/3/2009 11:05 PM Kumaresh
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.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: