SerializationWorkaround in Visual Studio!

SerializationWorkaround in Visual Studio!

Old forum URL: forums.lhotka.net/forums/t/2971.aspx


swegele posted on Thursday, May 31, 2007

I was having some trouble loading some of my forms in the Visual Studio designer.  The forms having trouble were inherited....let us say from BaseForm.  If BaseForm has a private module wide variable that was a business class the serialization "feature" was showing up.  Because BaseForm is actually running when VisualStudio is showing you the DerivedForm.  VisualStudio is compiling and running the BaseForm in order to show you the DerivedForm and the compiler notices this variable and tries to load the assembly and whamo.

It also worked to just make that variable as type Object and cast it as a business object later in the code.  But it gets tricky trying to think of every way that VisualStudio might stumble across some reference while in DesignMode=True.  So this works well.  I just handle the Load event on my BaseForm and if DesignMode = True then I call the serialization workaround code.

Just thought I would mention that here for others just incase they have similar trouble.

Sean

Copyright (c) Marimer LLC