By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,797 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

Mysterious bug in VS2005 which occasionally causes crash

P: n/a
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(StackCra wlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at
Microsoft.VisualStudio.Shell.Design.AssemblyObsole teEventArgs..ctor(Assembly
assembly)
at
Microsoft.VisualStudio.Design.VSDynamicTypeService .ReloadAssemblyIfChanged(String
codeBase)
at
Microsoft.VisualStudio.Design.VSDynamicTypeService .CreateDynamicAssembly(String
codeBase)
at
Microsoft.VisualStudio.Design.VSTypeResolutionServ ice.AssemblyEntry.get_Assembly()
at
Microsoft.VisualStudio.Design.VSTypeResolutionServ ice.AssemblyEntry.Search(String
fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly,
String description)
at
Microsoft.VisualStudio.Design.VSTypeResolutionServ ice.SearchProjectEntries(AssemblyName
assemblyName, String typeName, Boolean ignoreTypeCase, Assembly&
assembly)
at Microsoft.VisualStudio.Design.VSTypeResolutionServ ice.GetType(String
typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType
refType)
at
Microsoft.VisualStudio.Design.Serialization.CodeDo m.AggregateTypeResolutionService.GetType(String
name, Boolean throwOnError, Boolean ignoreCase)
at
Microsoft.VisualStudio.Design.Serialization.CodeDo m.AggregateTypeResolutionService.GetType(String
name)
at
System.ComponentModel.Design.DesignerHost.System.C omponentModel.Design.IDesignerHost.GetType(String
typeName)
at
System.ComponentModel.Design.Serialization.CodeDom DesignerLoader.EnsureDocument(IDesignerSerializati onManager
manager)
at
System.ComponentModel.Design.Serialization.CodeDom DesignerLoader.PerformLoad(IDesignerSerializationM anager
manager)
at
Microsoft.VisualStudio.Design.Serialization.CodeDo m.VSCodeDomDesignerLoader.PerformLoad(IDesignerSer ializationManager
serializationManager)
at
System.ComponentModel.Design.Serialization.BasicDe signerLoader.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.GetParametersN oCopy()
at System.Reflection.RuntimePropertyInfo.GetIndexPara meters()
at
System.ComponentModel.ReflectTypeDescriptionProvid er.ReflectGetProperties(Type
type)
at
System.ComponentModel.ReflectTypeDescriptionProvid er.ReflectedTypeData.GetProperties()
at
System.ComponentModel.TypeDescriptor.TypeDescripti onNode.DefaultTypeDescriptor.System.ComponentModel .ICustomTypeDescriptor.GetProperties()
at
System.ComponentModel.TypeDescriptor.TypeDescripti onNode.DefaultTypeDescriptor.System.ComponentModel .ICustomTypeDescriptor.GetProperties()
at System.ComponentModel.TypeDescriptor.GetProperties (Type
componentType)
at
System.Windows.Forms.Design.FormDocumentDesigner.I nitialize(IComponent
component)
at
System.ComponentModel.Design.DesignerHost.AddToCon tainerPostProcess(IComponent
component, String name, IContainer containerToAddTo)
at System.ComponentModel.Design.DesignerHost.Add(ICom ponent component,
String name)
at
System.ComponentModel.Design.DesignerHost.System.C omponentModel.Design.IDesignerHost.CreateComponent (Type
componentType, String name)
at
System.ComponentModel.Design.Serialization.Designe rSerializationManager.CreateInstance(Type
type, ICollection arguments, String name, Boolean addToContainer)
at
System.ComponentModel.Design.Serialization.Designe rSerializationManager.System.ComponentModel.Design .Serialization.IDesignerSerializationManager.Creat eInstance(Type
type, ICollection arguments, String name, Boolean addToContainer)
at
System.ComponentModel.Design.Serialization.TypeCod eDomSerializer.Deserialize(IDesignerSerializationM anager
manager, CodeTypeDeclaration declaration)
at
System.ComponentModel.Design.Serialization.CodeDom DesignerLoader.PerformLoad(IDesignerSerializationM anager
manager)
at
Microsoft.VisualStudio.Design.Serialization.CodeDo m.VSCodeDomDesignerLoader.PerformLoad(IDesignerSer ializationManager
serializationManager)
at
System.ComponentModel.Design.Serialization.BasicDe signerLoader.BeginLoad(IDesignerLoaderHost
host)

Mar 21 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I can't really see where you're driving at with this.

You have written a class (BaseForm) with a typo in it that is liable to
cause a stack overflow and yet you are you appear to be claiming that VS2005
has a bug in it.

Firstly System.Windows.Forms is a namespace and therfore I can't really
accept that you are deriving a class from it.

Secondly, neither of the stack traces indicate a call to the Count property
of your BaseForm.

If the Count property in your BasForm were to be called I would expect an
explicit stack overflow to be encountered with a few milliseconds.

When it comes to classes derived from System.Windows.Forms.Form, you have to
remember that code in the inherited class(es) may run when you load the
derived class in the designer. You have to implement code in the base
class(es) to cater for for this.
<sc*******@gmail.com> wrote in message
news:11*********************@t31g2000cwb.googlegro ups.com...
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(StackCra wlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at
Microsoft.VisualStudio.Shell.Design.AssemblyObsole teEventArgs..ctor(Assembly
assembly)
at
Microsoft.VisualStudio.Design.VSDynamicTypeService .ReloadAssemblyIfChanged(String
codeBase)
at
Microsoft.VisualStudio.Design.VSDynamicTypeService .CreateDynamicAssembly(String
codeBase)
at
Microsoft.VisualStudio.Design.VSTypeResolutionServ ice.AssemblyEntry.get_Assembly()
at
Microsoft.VisualStudio.Design.VSTypeResolutionServ ice.AssemblyEntry.Search(String
fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly,
String description)
at
Microsoft.VisualStudio.Design.VSTypeResolutionServ ice.SearchProjectEntries(AssemblyName
assemblyName, String typeName, Boolean ignoreTypeCase, Assembly&
assembly)
at Microsoft.VisualStudio.Design.VSTypeResolutionServ ice.GetType(String
typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType
refType)
at
Microsoft.VisualStudio.Design.Serialization.CodeDo m.AggregateTypeResolutionService.GetType(String
name, Boolean throwOnError, Boolean ignoreCase)
at
Microsoft.VisualStudio.Design.Serialization.CodeDo m.AggregateTypeResolutionService.GetType(String
name)
at
System.ComponentModel.Design.DesignerHost.System.C omponentModel.Design.IDesignerHost.GetType(String
typeName)
at
System.ComponentModel.Design.Serialization.CodeDom DesignerLoader.EnsureDocument(IDesignerSerializati onManager
manager)
at
System.ComponentModel.Design.Serialization.CodeDom DesignerLoader.PerformLoad(IDesignerSerializationM anager
manager)
at
Microsoft.VisualStudio.Design.Serialization.CodeDo m.VSCodeDomDesignerLoader.PerformLoad(IDesignerSer ializationManager
serializationManager)
at
System.ComponentModel.Design.Serialization.BasicDe signerLoader.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.GetParametersN oCopy()
at System.Reflection.RuntimePropertyInfo.GetIndexPara meters()
at
System.ComponentModel.ReflectTypeDescriptionProvid er.ReflectGetProperties(Type
type)
at
System.ComponentModel.ReflectTypeDescriptionProvid er.ReflectedTypeData.GetProperties()
at
System.ComponentModel.TypeDescriptor.TypeDescripti onNode.DefaultTypeDescriptor.System.ComponentModel .ICustomTypeDescriptor.GetProperties()
at
System.ComponentModel.TypeDescriptor.TypeDescripti onNode.DefaultTypeDescriptor.System.ComponentModel .ICustomTypeDescriptor.GetProperties()
at System.ComponentModel.TypeDescriptor.GetProperties (Type
componentType)
at
System.Windows.Forms.Design.FormDocumentDesigner.I nitialize(IComponent
component)
at
System.ComponentModel.Design.DesignerHost.AddToCon tainerPostProcess(IComponent
component, String name, IContainer containerToAddTo)
at System.ComponentModel.Design.DesignerHost.Add(ICom ponent component,
String name)
at
System.ComponentModel.Design.DesignerHost.System.C omponentModel.Design.IDesignerHost.CreateComponent (Type
componentType, String name)
at
System.ComponentModel.Design.Serialization.Designe rSerializationManager.CreateInstance(Type
type, ICollection arguments, String name, Boolean addToContainer)
at
System.ComponentModel.Design.Serialization.Designe rSerializationManager.System.ComponentModel.Design .Serialization.IDesignerSerializationManager.Creat eInstance(Type
type, ICollection arguments, String name, Boolean addToContainer)
at
System.ComponentModel.Design.Serialization.TypeCod eDomSerializer.Deserialize(IDesignerSerializationM anager
manager, CodeTypeDeclaration declaration)
at
System.ComponentModel.Design.Serialization.CodeDom DesignerLoader.PerformLoad(IDesignerSerializationM anager
manager)
at
Microsoft.VisualStudio.Design.Serialization.CodeDo m.VSCodeDomDesignerLoader.PerformLoad(IDesignerSer ializationManager
serializationManager)
at
System.ComponentModel.Design.Serialization.BasicDe signerLoader.BeginLoad(IDesignerLoaderHost
host)

Mar 22 '06 #2

P: n/a
I guess I did not state things clearly. It first appeared to be a bug
in VS2005, but it turned out to be a recursive call in our code.

What I am driving at, or more accurately, why I made the posting is to
help out others that run into the same problem in their code. I am
hoping that someone else will search the news groups, find my posting
and say: Ah, let me look for a recursive call in my code!

It took two developers a day and a half to find this, I am hoping
others can benefit from what we learned.

As far as a explicit stack overflow, there isn't one. I believe the
reason is because VS2005 is using reflection to call into our code
right before it displays the designer and crashes not expecting a stack
overflow. I have a feeling this is not something Microsoft can help,
thus it is what it is.

Sam

Mar 22 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.