That's cool (that's real not sarcastic), it's good to know the real reason
for why it happens (and that it's not something we did wrong).  I still
think maybe the implementation leaves a bit to be desired, but hey it's a
first release and maybe there was no way around it anyway. I still would
place it pretty high my wish list (along with visual inheritance for
webforms).

Thanks again,

John Deal

-----Original Message-----
From: Marsh, Drew [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 22, 2002 12:08 PM
To: [EMAIL PROTECTED]
Subject: Re: [DOTNET] ASP.Net Abstract Base Page Inheritance


DEAL John M [mailto:[EMAIL PROTECTED]] wrote:

> I don't quite buy into the "designer attempts to instantiate the Page
> class... and of course it can't instantiate an
> *abstract* class" aspect of it.  The point is the page that is being
> designed is a concrete version of the abstract class and it is that
> concrete class that should be being instantiated (no different than at
> runtime).  I could buy if it complained that I hadn't implemented an
> abstract method in my concrete class, but not that the designer should
> be trying to instantiate the abstract itself (what would be the point
> of inheritance if you never got to the concrete class?). I'm
> really not trying to be difficult, I just don't see why the
> designer would ever try and instantiate the abstract class.

Ok... lemme break this down for ya a bit. Here's what I've come to
understand while diving into the guts of this stuff for fun. When designing
a WebForm, it instantiates the base Page class, *not* the Page class being
designed. So when this happens in your scenario you get:

System.Runtime.Serialization.SerializationException: Type Abstract
   at
Microsoft.VSDesigner.WebForms.RootCodeDomSerializer.Deserialize(IDesignerSer
ializationManager manager, Object codeObject)
   at Microsoft.VisualStudio.Designer.Serialization.CodeDomLoader.Load()
   at
Microsoft.VisualStudio.Designer.Serialization.BaseDesignerLoader.Load()

Specifically, this comes from the following IL:

<codeSnippet language="C#">
  IL_0160:  callvirt   instance string
[System]System.CodeDom.CodeTypeReference::get_BaseType()
  IL_0165:  stelem.ref
  IL_0166:  ldloc.s    V_8
  IL_0168:  call       string Microsoft.VSDesigner.SR::GetString(string,
                                                                 object[])
  IL_016d:  newobj     instance void
[mscorlib]System.Runtime.Serialization.SerializationException::.ctor(string)
  IL_0172:  throw
  IL_0173:  ldloc.s    V_7
  IL_0175:  callvirt   instance bool [mscorlib]System.Type::get_IsAbstract()
  IL_017a:  brfalse.s  IL_01a1
  IL_017c:  ldstr      "WFD_TypeAbstract"
  IL_0181:  ldc.i4.1
  IL_0182:  newarr     [mscorlib]System.Object
  IL_0187:  stloc.s    V_8
  IL_0189:  ldloc.s    V_8
  IL_018b:  ldc.i4.0
  IL_018c:  ldloc.s    V_7
  IL_018e:  callvirt   instance string [mscorlib]System.Type::get_FullName()
  IL_0193:  stelem.ref
  IL_0194:  ldloc.s    V_8
  IL_0196:  call       string Microsoft.VSDesigner.SR::GetString(string,
                                                                 object[])
  IL_019b:  newobj     instance void
[mscorlib]System.Runtime.Serialization.SerializationException::.ctor(string)
  IL_01a0:  throw
</codeSnippet>

Basically, IL_0160 get's the base type of the page class in preparation to
instantiate it for help with design. However, you see at IL_0175 the check
to make sure it's not abstract. Since your base class is abstract, you get
the error you're seeing. Otherwise IL_017a breaks to IL_01a1 which
eventually leads to instantiating the base class and continues forward with
design.

HTH,
Drew
.NET MVP

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to