Nearly EVER TIME I open a form, the designer is unable to load the form with weird & mysetrious errors (see sample errors below). How is anyone supposed to develop like this? To try and resolve the problem, I have to try any of these: 1) Close the form and open it again 2) Close form, recompile solution, open form 3) Close visual studio and open up project again Again, this is 80% of the time I try and open up a form inside Visual Studio 2005 by double click the form (even right after a successful build). I am not exaggerating. This has brought our teams productivity to a near stand still and is completely frustrating. What are we doing wrong? In addition to forms not opening, we CONSTANTLY get failed builds due to some process locking another process on some file during the build process. Any help is MUCH appreciated and desperately needed. Error messages when opening forms include: 1) Not legal path (what the heck does this mean?) 2) Unable to load one or more of the requested types (see below) 3) Blah blah resource could not be loaded (but resource IS there and builds and runs just fine but the designer fails) Sample error below:
Unable to load one or more of the requested types. Retrieve the LoaderExceptions
property for more information. Hide |
|
at
System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark) at
System.Reflection.Assembly.GetTypes() at
Microsoft.VisualStudio.Shell.Design.AssemblyObsoleteEventArgs..ctor(Assembly
assembly) at
Microsoft.VisualStudio.Design.VSDynamicTypeService.ReloadAssemblyIfChanged(String
codeBase) at
Microsoft.VisualStudio.Design.VSDynamicTypeService.CreateDynamicAssembly(String
codeBase) at
Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_Assembly() at
Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String
fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly,
String description) at
Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchNormalEntries(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) at
System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.GetType(String
typeName) at
System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager
manager) 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)
| | | bensterdev Friday, March 31, 2006 1:39 AM | Hi!
Most often designer problems come when you use own controls that do not respect DesignMode property. For example, you may have some control that issue some resource read or static class access operations that may not be valid at design time.
Another reason why designer can't load is syntax error in source, but this is easy to see and fix. | | Sergey Galich Friday, March 31, 2006 2:07 AM | Greetings:
No, this is not the case. Here's why:
1) Complex or simple forms will fail. Thats the ones with custom controls and the ones without custom controls. This happens with all forms in 2005 but not in 2003. 2) Simply closing and opening the same form immediately will sometimes resolve the issue (no changes to the code or recompiling necessary). Sometimes you have to close and open the form 2 or 3 times to resolve the issue.
Any other ideas?
| | bensterdev Friday, March 31, 2006 2:10 AM | Welcome to hell.
The designer spins up an instance of your form using only *some* of your code. I reported this as a bug, but it's apparently 'by design'. What it means is, you need to code VERY defensively in your forms. Consider which events you've created that will fire when the form is shown by the designer. Consider all your member variables, do you always check if they are a value you expect before using them ? One example that took me a while to pick - I had a form with a bitmap on it. I assumed in my code it was a particular bit depth. My code just checked if the bitmap was null, otherwise, I assumed my bitmap creating code had made a bitmap of the right bit depth. The designer was stuffing a bitmap of PixelFormat.Undetermined into that property, which I didn't even know existed, and gave me one of the exact sort of errors you describe ( from memory, that was the one that plain crashed the IDE every time I tried to open design view )
Moving from a VS2003 project is a nightmare because of these issues, but the good news is, once you understand the cause and fix the ones you have, you'll find it pretty much second nature to code in a way that stops it happening any more. And I will (grudgingly ) accept that my code is theoretically better for the changes I am making, even if none of them would make a spot of difference in the real world.
| | cgraus Friday, March 31, 2006 2:11 AM | Thank you. I do check for design mode when required. But, my application isn't that complex. Its a simple data entry application. Started having this problem after migrating my project from Visual Studio 2003 to Visual Studio 2005.
If the problem is my code, then it should be reasoned that simply closing the form window and reopening it immediately should not resolve the error. In fact, if it is a coding problem, I should have the failure 100% of the time. But, right now, for me, opening a form is hit or miss. All of this without changing any code. I even tried "Clean Solution" in the build menu but I don't even know what that does.
I'm really thinking the VS2005 designer is just poorly designed. I'm thinking something went wrong during the migration (even though no errors were reported). Should I just create new projects from scratch and cut and paste all my code into the new project? What a headache!
Any other ideas?
| | bensterdev Friday, March 31, 2006 2:17 AM | By the way, I am a relatively seasoned .NET developer. Have been doing c# ever since it was released way back when (2001? or 2002?). Have been accustomed to any quirks in 2003. But, VS2005, gosh, I've poked everywhere I can.
| | bensterdev Friday, March 31, 2006 2:20 AM | I have to admit, I really understand what you're saying. I went through it. However, I also found that sometimes my form opened and sometimes it would not. Specifically, if I opened the form for the first time, it would work, if I browsed away to code and came back, it would crash. I suspect the code in InitializeComponent, which gets updated every time, was the reason for this.
// I'm really thinking the VS2005 designer is just poorly designed.
I tend to agree, but the official position is that it's become less forgiving as a feature, so we clean up our code :-)
The IDE does show you in the error list where it's having the trouble, you might want to look there. I doubt that recreating your project will help. Perhaps creating a copy and removing controls one at a time to see which one causes the crash is a reasonable approach to take.
| | cgraus Friday, March 31, 2006 2:21 AM | *grin* I assumed you were experienced, mostly because this problem only happens when migrating projects, so you obviously have been coding in VS2003, at least :-)
| | cgraus Friday, March 31, 2006 2:22 AM | Most of my code resides on Form_Load typically. No special initializations done in InitializeComponent() except whats autogenerated by VS.Net2003/2005. I do look at the error messages and its usually something in the internals to the framework or VS.NET. Here's another error message I just got. Did not change the code on the form at all (I swear!). Was working fine a minute ago. This is the MOST common problem. As you can see, its not even near calling the "InitializeComponent()" method.
|
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. |
The path is not of a legal form. Hide |
|
at
System.IO.Path.NormalizePathFast(String path, Boolean fullCheck) at
System.IO.Path.GetFullPathInternal(String path) at
System.Reflection.AssemblyName.GetAssemblyName(String assemblyFile) at
Microsoft.VisualStudio.Design.VSTypeResolutionService.AddProjectDependencies(Project
project) at
Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_Assembly() at
Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String
fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly,
String description) at
Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchProjectEntries(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) at
System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.GetType(String
typeName) at
System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager
manager) 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)
|
Here is the InitializeComponentMethod: public FormRecordDetail() { InitializeComponent(); <-- Code auto-generated by VS.NET2003/2005 } The form has two contructors: public FormRecordDetail(object data) { MyData = data; } Although I have changed the names of the variables for privacy reasons, this is the code AS-IS otherwise. This is just one form and one example. This error displayed by VS.NET 2005 happens with all forms of all shape and size and construct. If you need more information from me, please let me know. | | bensterdev Friday, March 31, 2006 6:39 AM | One more thing, I just closed that error and double clicked on the form again. Presto, its back. No code changes, did not re-comple, just double clicked. (I SWEAR!)
| | bensterdev Friday, March 31, 2006 6:42 AM | Another error:
| 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. |
Unable to load one or more of the requested types.
Retrieve the LoaderExceptions property for more information. Hide |
|
at
System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark) at
System.Reflection.Assembly.GetTypes() at
Microsoft.VisualStudio.Shell.Design.AssemblyObsoleteEventArgs..ctor(Assembly
assembly) at
Microsoft.VisualStudio.Design.VSDynamicTypeService.ReloadAssemblyIfChanged(String
codeBase) at
Microsoft.VisualStudio.Design.VSDynamicTypeService.CreateDynamicAssembly(String
codeBase) at
Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_Assembly() at
Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String
fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly,
String description) at
Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchProjectEntries(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) at
System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.GetType(String
typeName) at
System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager
manager) 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)
| | | bensterdev Friday, March 31, 2006 7:02 AM | Today I find another way to break form designer, nothing special, just playing with two DataGridViews, no hand coding and no custom controls. Lucky me I find the way to manually fix problem later in source code. Yes, forms designer is stuff thatisn't stabilized well.
What controls do you have in your form? Standard only or custom too? Do you use controls that may autogenerate stuff, like DataGridView, that generate columns (arrghhh!) when I set DataSource (and I already made necessary columns by hands ).
All designer problems comes from fact that it create form's base class(Form typically) and place in it all controls, that compiled in temporary assembly. Due this fact it's really good to code controls with less coupling, i.e. they must reference other types as less as possible.
Another reason of yourtrouble (which is really bigger than mine - my VS crashes rarely) - you may have beta version. It's theoretical, but possible.
And one (my favorite ) problem with VS is that it use caching here and there. I know that toolbox caching are not stable yet and even reinstalling VS may not help (uninstall leave cache as is). Probably there is some designers caches or other caching took place? Hard to help here, but at least you can try empty Temp folder, shouldn't hurt.
Anyway you better report this bug here http://lab.msdn.microsoft.com/productfeedback/default.aspx, so MS will take care & fix it. | | Sergey Galich Friday, March 31, 2006 7:12 AM | Another error. Can anyone help? I've reported to Microsoft but I don't expect any answers soon from them. In the meantime, I'm helping some galant genius can come to the rescue:
| 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 'eBayApp,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its
dependencies. The system cannot find the file specified. Hide |
|
at
System.Signature._GetSignature(SignatureStruct& signature, Void* pCorSig,
Int32 cCorSig, IntPtr fieldHandle, IntPtr methodHandle, IntPtr
declaringTypeHandle) at System.Signature.GetSignature(SignatureStruct&
signature, Void* pCorSig, Int32 cCorSig, RuntimeFieldHandle fieldHandle,
RuntimeMethodHandle methodHandle, RuntimeTypeHandle declaringTypeHandle) at
System.Signature..ctor(RuntimeMethodHandle methodHandle, RuntimeTypeHandle
declaringTypeHandle) at
System.Reflection.RuntimeMethodInfo.get_Signature() at
System.Reflection.RuntimeMethodInfo.GetParametersNoCopy() at
System.Reflection.RuntimePropertyInfo.GetIndexParameters() at
System.ComponentModel.ReflectTypeDescriptionProvider.ReflectGetProperties(Type
type) at
System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetProperties() at
System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties() at
System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties() at
System.ComponentModel.TypeDescriptor.GetProperties(Type componentType) at
System.Windows.Forms.Design.ControlDesigner.Initialize(IComponent
component) at
System.Windows.Forms.Design.ComboBoxDesigner.Initialize(IComponent
component) at
System.ComponentModel.Design.DesignerHost.AddToContainerPostProcess(IComponent
component, String name, IContainer containerToAddTo) at
System.ComponentModel.Design.DesignerHost.Add(IComponent component, String
name) at
System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type
componentType, String name) at
System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type
type, ICollection arguments, String name, Boolean addToContainer) at
System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type
type, ICollection arguments, String name, Boolean addToContainer) at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeInstance(IDesignerSerializationManager
manager, Type type, Object[] parameters, String name, Boolean
addToContainer) at
System.ComponentModel.Design.Serialization.ComponentCodeDomSerializer.DeserializeInstance(IDesignerSerializationManager
manager, Type type, Object[] parameters, String name, Boolean
addToContainer) at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager
manager, String name, CodeExpression expression) at
System.ComponentModel.Design.Serialization.CodeDomSerializer.DeserializeStatementToInstance(IDesignerSerializationManager
manager, CodeStatement statement) at
System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(IDesignerSerializationManager
manager, Object codeObject) at
System.Windows.Forms.Design.ControlCodeDomSerializer.Deserialize(IDesignerSerializationManager
manager, Object codeObject) at
System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.DeserializeName(IDesignerSerializationManager
manager, String name, CodeStatementCollection statements)
|
The variable 'cmbStoreAuction' is either undeclared
or was never assigned. HideEdit |
|
at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager
manager, String exceptionText, String helpLink) at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager
manager, String name, CodeExpression expression) at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager
manager, String name, CodeExpression expression) at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager
manager, CodeStatement statement)
|
Could not load file or assembly 'xxxxApp,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its
dependencies. The system cannot find the file specified. Hide |
|
at
System.Signature._GetSignature(SignatureStruct& signature, Void* pCorSig,
Int32 cCorSig, IntPtr fieldHandle, IntPtr methodHandle, IntPtr
declaringTypeHandle) at System.Signature.GetSignature(SignatureStruct&
signature, Void* pCorSig, Int32 cCorSig, RuntimeFieldHandle fieldHandle,
RuntimeMethodHandle methodHandle, RuntimeTypeHandle declaringTypeHandle) at
System.Signature..ctor(RuntimeMethodHandle methodHandle, RuntimeTypeHandle
declaringTypeHandle) at
System.Reflection.RuntimeMethodInfo.get_Signature() at
System.Reflection.RuntimeMethodInfo.GetParametersNoCopy() at
System.Reflection.RuntimePropertyInfo.GetIndexParameters() at
System.ComponentModel.ReflectTypeDescriptionProvider.ReflectGetProperties(Type
type) at
System.ComponentModel.ReflectTypeDescriptionProvider.ReflectedTypeData.GetProperties() at
System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties() at
System.ComponentModel.TypeDescriptor.TypeDescriptionNode.DefaultTypeDescriptor.System.ComponentModel.ICustomTypeDescriptor.GetProperties() at
System.ComponentModel.TypeDescriptor.GetProperties(Type componentType) at
System.Windows.Forms.Design.ControlDesigner.Initialize(IComponent
component) at
System.Windows.Forms.Design.ComboBoxDesigner.Initialize(IComponent
component) at
System.ComponentModel.Design.DesignerHost.AddToContainerPostProcess(IComponent
component, String name, IContainer containerToAddTo) at
System.ComponentModel.Design.DesignerHost.Add(IComponent component, String
name) at
System.ComponentModel.Design.DesignerHost.System.ComponentModel.Design.IDesignerHost.CreateComponent(Type
componentType, String name) at
System.ComponentModel.Design.Serialization.DesignerSerializationManager.CreateInstance(Type
type, ICollection arguments, String name, Boolean addToContainer) at
System.ComponentModel.Design.Serialization.DesignerSerializationManager.System.ComponentModel.Design.Serialization.IDesignerSerializationManager.CreateInstance(Type
type, ICollection arguments, String name, Boolean addToContainer) at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeInstance(IDesignerSerializationManager
manager, Type type, Object[] parameters, String name, Boolean
addToContainer) at
System.ComponentModel.Design.Serialization.ComponentCodeDomSerializer.DeserializeInstance(IDesignerSerializationManager
manager, Type type, Object[] parameters, String name, Boolean
addToContainer) at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager
manager, String name, CodeExpression expression) at
System.ComponentModel.Design.Serialization.CodeDomSerializer.DeserializeStatementToInstance(IDesignerSerializationManager
manager, CodeStatement statement) at
System.ComponentModel.Design.Serialization.CodeDomSerializer.Deserialize(IDesignerSerializationManager
manager, Object codeObject) at
System.Windows.Forms.Design.ControlCodeDomSerializer.Deserialize(IDesignerSerializationManager
manager, Object codeObject) at
System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.DeserializeName(IDesignerSerializationManager
manager, String name, CodeStatementCollection statements)
|
The variable 'cmb' is either
undeclared or was never assigned. HideEdit |
|
at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.Error(IDesignerSerializationManager
manager, String exceptionText, String helpLink) at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager
manager, String name, CodeExpression expression) at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeExpression(IDesignerSerializationManager
manager, String name, CodeExpression expression) at
System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager
manager, CodeStatement statement)
| | | bensterdev Friday, March 31, 2006 4:59 PM | "Path is not of a legal Form".
We have gotten customer feedback on this error reported here:
http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackid=3d84fe85-d2c1-43b0-9724-6fd641506456
The only cause that we have been able to determine is that one of the references in the project is invalid (doesn't point to anything). This causes an exception when the designer attempts to load. There may be other causes and if you can describe a repro (shorthand for "reproduce the error"), please reactivate the product feedback issue or create a new one.
To fix this issue, ensure that all of your references do not have yellow warnings and are properly resolved (click on thier properties and see that each points to an assembly with some path).
"Could not load file or Assembly"
This may happen if you do not have that assembly referenced in your project. If you are sure you do -- then this could be a product bug and I urge you to use the product feedback site to create a bug on it.
In your particular callstack, it looks like the Type is being used either as a Property type or an attribute on a property.
We know that this White Screen of Darn is really annoying. We are looking at addressing this by both increasing the helpfulness of the error messages and eliminating any product bugs that may make this more frequent.
We do need this error screen to stop any further work on the designer because if we ignored errors (as we did in VS2003), then it may cause data loss.
So, I would urge anyone who is encountering frequent issues like this to use the product feedback site. We will be enumerating all occurrences for message "helpfulness" and we will be fixing product issues that cause it.
| | Benjamin Wulfe - MS Friday, March 31, 2006 5:50 PM |
|