| re: XmlDocument Inheritance problem
Having overridden those methods, when the XmlDocument needs to call them for
some reason, nothing will happen. You should be able to just delete those
methods, but if you HAVE to have them, simply add
MyBase.FunctionName(params) (Example: MyBase.CloneNode(w)) to the last line
of the method. Calling the MyBase version of the function tells VB to "do
whatever the function is supposed to do" in addition to what your override
does. I'm rambling, but I hope this makes sense.
"Robin Hay" <hayrob@btconnect.com> wrote in message
news:029a01c37e0a$b0f2a2d0$a301280a@phx.gbl...[color=blue]
> I have created a class which inherits from XmlDocument.
> It works as I expected.
> If I use Visual Studio, and type a <carriage return> after
> "inherits XmlDocument", VS adds three method overrides.
> These seem to make sense, but then the class doesn't
> behave as I intended, or as it did if I typed in the data
> myself. See example below.
>
> Imports System.xml
> Module Module1
>
> Sub Main()
> Dim doc1 As New SimpleInheritance
> Dim doc2 As New VisualStudioInheritance
>
> End Sub
>
> End Module
> Public Class SimpleInheritance
> Inherits XmlDocument
>
> Public Sub New()
> MyBase.New()
> LoadXml("<tag>text</tag>")
> Console.WriteLine("SimpleInheritance: " &
> OuterXml & "End of text")
> End Sub
> End Class
> Public Class VisualStudioInheritance
> Inherits XmlDocument
> Public Sub New()
> MyBase.New()
> LoadXml("<tag>text</tag>")
> Console.WriteLine("VisualStudioInheritance: " &
> OuterXml & "End of text")
>
> End Sub
> Public Overrides Function CloneNode(ByVal deep As
> Boolean) As System.Xml.XmlNode
>
> End Function
>
> Public Overrides Sub WriteContentTo(ByVal w As
> System.Xml.XmlWriter)
>
> End Sub
>
> Public Overrides Sub WriteTo(ByVal w As
> System.Xml.XmlWriter)
>
> End Sub
> End Class
>
>
> I cann't see why the three methods have the effect that
> they do. Sure it's obvious, but help would be
> appreciated........
> Thanks
>
> Robin Hay
>[/color] |