S
scarleton
A coworker and I have spent the last day and a half trying to track
down this bug in our code. We found the solution and thought we might
post it to help others out...
The setup: Class FinalForm derives from Class BaseForm that derives
from System.Windows.Forms.
public class BaseForm : Forms {}
public class FinalForm : BaseForm {}
When trying to open class FinalForm in the designer one of a number of
error happens which are listed at the bottom, they are a bit long so
here is what was causing the problem, and the fix:
The problem:
A recursive call within the base class BaseForm:
public class BaseForm : Forms
{
int count =0;
public int Count
{
get { return Count; }
}
}
The Count's getter should be returning count, but is calling itself!
Once it returns the right thing, all is well.
I hope this helps out others!
Sam
The differen errors we saw, there might be more:
1: VS2005 crashes and either simply goes away or gives the dialog to
report the error to Microsoft.
2: 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)
3: 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 '<my assembly>, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=12e8b3ea4074fce4' 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.FormDocumentDesigner.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.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)
down this bug in our code. We found the solution and thought we might
post it to help others out...
The setup: Class FinalForm derives from Class BaseForm that derives
from System.Windows.Forms.
public class BaseForm : Forms {}
public class FinalForm : BaseForm {}
When trying to open class FinalForm in the designer one of a number of
error happens which are listed at the bottom, they are a bit long so
here is what was causing the problem, and the fix:
The problem:
A recursive call within the base class BaseForm:
public class BaseForm : Forms
{
int count =0;
public int Count
{
get { return Count; }
}
}
The Count's getter should be returning count, but is calling itself!
Once it returns the right thing, all is well.
I hope this helps out others!
Sam
The differen errors we saw, there might be more:
1: VS2005 crashes and either simply goes away or gives the dialog to
report the error to Microsoft.
2: 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)
3: 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 '<my assembly>, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=12e8b3ea4074fce4' 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.FormDocumentDesigner.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.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)