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

Problem in deriving class from XmlNode BCL class

P: n/a
Hi All,
I want to make a custom class in c#, which extends System.Xml.XmlNode class
of BCL.

Now in custom class, I have implement abstract methods of XmlNode class
also. Now when I am trying to run the class it gives an error that
"System.Xml.XmlNode.XmlNode() is inaccessible due to its protection level".

This error comes because XmlNode has not any public constructor. I found
XmlNode has two constructor but both are private or friend (i dont know
exactly).

I also found one MSDN article where it says that "Never derive any class
directly from XmlNode" but its just recommendation.
(http://msdn.microsoft.com/library/de...-us/cpguide/ht
ml/cpconextendingdom.asp)

Though, Microsoft has derived some of BCL classes from base XmlNode, so why
we can not derive?
System.Object
System.Xml.XmlNode
System.Xml.XmlAttribute
System.Xml.XmlDocument
System.Xml.XmlDocumentFragment
System.Xml.XmlEntity
System.Xml.XmlLinkedNode
System.Xml.XmlNotation

So i think there must be some way out of this....

So what to do to create a derived class from XmlNode?
I heard that many experts are giving their service in news groups. So please
help me out of this.

I have already derived few of my classes from XmlDocument, XmlElement,
XmlAttribute etc. So i dont want to derive from them but i want to derive
the class from XmlNode it self. Please help me to get the answer...

Thanks in Advance.

Thanking you,
Mahesh Devjibhai Dhola
"Empower yourself...."
Nov 16 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Unfortunately, you can not derive from System.Xml.XmlNode, because
the two constructors defined are both internal.

I would like to know in which context you are coming across to be needing to
derive
a class from XmlNode, and what is it that you are trying to achieve?

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Mahesh Devjibhai Dhola" <md*****@hotmail.com> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
Hi All,
I want to make a custom class in c#, which extends System.Xml.XmlNode
class
of BCL.

Now in custom class, I have implement abstract methods of XmlNode class
also. Now when I am trying to run the class it gives an error that
"System.Xml.XmlNode.XmlNode() is inaccessible due to its protection
level".

This error comes because XmlNode has not any public constructor. I found
XmlNode has two constructor but both are private or friend (i dont know
exactly).

I also found one MSDN article where it says that "Never derive any class
directly from XmlNode" but its just recommendation.
(http://msdn.microsoft.com/library/de...-us/cpguide/ht
ml/cpconextendingdom.asp)

Though, Microsoft has derived some of BCL classes from base XmlNode, so
why
we can not derive?
System.Object
System.Xml.XmlNode
System.Xml.XmlAttribute
System.Xml.XmlDocument
System.Xml.XmlDocumentFragment
System.Xml.XmlEntity
System.Xml.XmlLinkedNode
System.Xml.XmlNotation

So i think there must be some way out of this....

So what to do to create a derived class from XmlNode?
I heard that many experts are giving their service in news groups. So
please
help me out of this.

I have already derived few of my classes from XmlDocument, XmlElement,
XmlAttribute etc. So i dont want to derive from them but i want to derive
the class from XmlNode it self. Please help me to get the answer...

Thanks in Advance.

Thanking you,
Mahesh Devjibhai Dhola
"Empower yourself...."

Nov 16 '05 #2

P: n/a
Hi Dennis,
Thanking you very much for your reply...
I thought the same thing that i will not be able to derive class from it.
Is there any document which says about its constructors? So i could know...

What is the intention of microsoft not to make it derivable? If Microsoft do
not want to make it derivable then it should declare that class as sealed or
final, not abstract? what is the design aspect behind that?

My real intention is to make my own xml assembly, which in fact is wrapper
of all the System.Xml classes with my own added functionalities in each
classes. I want all those classes but it should be mine not Microsoft. So i
am deriving those classes from System.Xml and making my own custom classes
with the changed class name, and added my own functioanlities in addition to
available facilities of extended class from System.Xml

Can you give me some way?

Thanks in advance....
"Dennis Myrén" <de****@oslokb.no> wrote in message
news:If******************@news2.e.nsc.no...
Unfortunately, you can not derive from System.Xml.XmlNode, because
the two constructors defined are both internal.

I would like to know in which context you are coming across to be needing to derive
a class from XmlNode, and what is it that you are trying to achieve?

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Mahesh Devjibhai Dhola" <md*****@hotmail.com> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
Hi All,
I want to make a custom class in c#, which extends System.Xml.XmlNode
class
of BCL.

Now in custom class, I have implement abstract methods of XmlNode class
also. Now when I am trying to run the class it gives an error that
"System.Xml.XmlNode.XmlNode() is inaccessible due to its protection
level".

This error comes because XmlNode has not any public constructor. I found
XmlNode has two constructor but both are private or friend (i dont know
exactly).

I also found one MSDN article where it says that "Never derive any class
directly from XmlNode" but its just recommendation.
(http://msdn.microsoft.com/library/de...-us/cpguide/ht ml/cpconextendingdom.asp)

Though, Microsoft has derived some of BCL classes from base XmlNode, so
why
we can not derive?
System.Object
System.Xml.XmlNode
System.Xml.XmlAttribute
System.Xml.XmlDocument
System.Xml.XmlDocumentFragment
System.Xml.XmlEntity
System.Xml.XmlLinkedNode
System.Xml.XmlNotation

So i think there must be some way out of this....

So what to do to create a derived class from XmlNode?
I heard that many experts are giving their service in news groups. So
please
help me out of this.

I have already derived few of my classes from XmlDocument, XmlElement,
XmlAttribute etc. So i dont want to derive from them but i want to derive the class from XmlNode it self. Please help me to get the answer...

Thanks in Advance.

Thanking you,
Mahesh Devjibhai Dhola
"Empower yourself...."


Nov 16 '05 #3

P: n/a
Mahesh,
Is there any document which says about its constructors? So i could know... MSDN provides documentation on the .NET Framework SDK.
System.Xml.XmlNode documentation can be found here:
http://msdn.microsoft.com/library/de...classtopic.asp

Also, great software for viewing .NET assemblies is
Lutz Roeder's .NET Reflector.
You should download that. It is free and can be downloaded from here:
http://www.aisto.com/roeder/dotnet/
What is the intention of microsoft not to make it derivable? If Microsoft
do
not want to make it derivable then it should declare that class as sealed
or
final, not abstract? what is the design aspect behind that? The reason it is inheritable(not sealed) is it works as a base class
for a number of classes in the system.xml.dll,
including XmlDocument and XmlElement(indirect via XmlLinkedNode).
I do not know though, why the constructurs are internal rather than
protected.
I guess they do now want anyone to derive XmlNode.
Can you give me some way? Well, most of the core logic is provided by XmlElement i think.
Maybe you could write your own XmlNode and derive from XmlElement.

Otherwise, i am afraid i really do not have any good advice for you.
Other than, of course, create an actual wrapper not inherited from,
but rather utilizing XmlNode internally.
That will request a great deal of code though.
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Mahesh Devjibhai Dhola" <md*****@hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP10.phx.gbl... Hi Dennis,
Thanking you very much for your reply...
I thought the same thing that i will not be able to derive class from it.
Is there any document which says about its constructors? So i could
know...

What is the intention of microsoft not to make it derivable? If Microsoft
do
not want to make it derivable then it should declare that class as sealed
or
final, not abstract? what is the design aspect behind that?

My real intention is to make my own xml assembly, which in fact is wrapper
of all the System.Xml classes with my own added functionalities in each
classes. I want all those classes but it should be mine not Microsoft. So
i
am deriving those classes from System.Xml and making my own custom classes
with the changed class name, and added my own functioanlities in addition
to
available facilities of extended class from System.Xml

Can you give me some way?

Thanks in advance....
"Dennis Myrén" <de****@oslokb.no> wrote in message
news:If******************@news2.e.nsc.no...
Unfortunately, you can not derive from System.Xml.XmlNode, because
the two constructors defined are both internal.

I would like to know in which context you are coming across to be needing

to
derive
a class from XmlNode, and what is it that you are trying to achieve?

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Mahesh Devjibhai Dhola" <md*****@hotmail.com> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
> Hi All,
> I want to make a custom class in c#, which extends System.Xml.XmlNode
> class
> of BCL.
>
> Now in custom class, I have implement abstract methods of XmlNode class
> also. Now when I am trying to run the class it gives an error that
> "System.Xml.XmlNode.XmlNode() is inaccessible due to its protection
> level".
>
> This error comes because XmlNode has not any public constructor. I
> found
> XmlNode has two constructor but both are private or friend (i dont know
> exactly).
>
> I also found one MSDN article where it says that "Never derive any
> class
> directly from XmlNode" but its just recommendation.
> (http://msdn.microsoft.com/library/de...-us/cpguide/ht > ml/cpconextendingdom.asp)
>
> Though, Microsoft has derived some of BCL classes from base XmlNode, so
> why
> we can not derive?
> System.Object
> System.Xml.XmlNode
> System.Xml.XmlAttribute
> System.Xml.XmlDocument
> System.Xml.XmlDocumentFragment
> System.Xml.XmlEntity
> System.Xml.XmlLinkedNode
> System.Xml.XmlNotation
>
> So i think there must be some way out of this....
>
> So what to do to create a derived class from XmlNode?
> I heard that many experts are giving their service in news groups. So
> please
> help me out of this.
>
> I have already derived few of my classes from XmlDocument, XmlElement,
> XmlAttribute etc. So i dont want to derive from them but i want to derive > the class from XmlNode it self. Please help me to get the answer...
>
> Thanks in Advance.
>
> Thanking you,
> Mahesh Devjibhai Dhola
> "Empower yourself...."
>
>



Nov 16 '05 #4

P: n/a
You may also look at the MONO project
which provides an open-source implementation of the entire (well, almost)
..NET Framework:
It can be downloaded from here:
http://www.mono-project.com/downloads/

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Dennis Myrén" <de****@oslokb.no> wrote in message
news:a6******************@news2.e.nsc.no...
Mahesh,
Is there any document which says about its constructors? So i could
know...

MSDN provides documentation on the .NET Framework SDK.
System.Xml.XmlNode documentation can be found here:
http://msdn.microsoft.com/library/de...classtopic.asp

Also, great software for viewing .NET assemblies is
Lutz Roeder's .NET Reflector.
You should download that. It is free and can be downloaded from here:
http://www.aisto.com/roeder/dotnet/
What is the intention of microsoft not to make it derivable? If Microsoft
do
not want to make it derivable then it should declare that class as sealed
or
final, not abstract? what is the design aspect behind that?

The reason it is inheritable(not sealed) is it works as a base class
for a number of classes in the system.xml.dll,
including XmlDocument and XmlElement(indirect via XmlLinkedNode).
I do not know though, why the constructurs are internal rather than
protected.
I guess they do now want anyone to derive XmlNode.
Can you give me some way?

Well, most of the core logic is provided by XmlElement i think.
Maybe you could write your own XmlNode and derive from XmlElement.

Otherwise, i am afraid i really do not have any good advice for you.
Other than, of course, create an actual wrapper not inherited from,
but rather utilizing XmlNode internally.
That will request a great deal of code though.
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Mahesh Devjibhai Dhola" <md*****@hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP10.phx.gbl...
Hi Dennis,
Thanking you very much for your reply...
I thought the same thing that i will not be able to derive class from it.
Is there any document which says about its constructors? So i could
know...

What is the intention of microsoft not to make it derivable? If Microsoft
do
not want to make it derivable then it should declare that class as sealed
or
final, not abstract? what is the design aspect behind that?

My real intention is to make my own xml assembly, which in fact is
wrapper
of all the System.Xml classes with my own added functionalities in each
classes. I want all those classes but it should be mine not Microsoft. So
i
am deriving those classes from System.Xml and making my own custom
classes
with the changed class name, and added my own functioanlities in addition
to
available facilities of extended class from System.Xml

Can you give me some way?

Thanks in advance....
"Dennis Myrén" <de****@oslokb.no> wrote in message
news:If******************@news2.e.nsc.no...
Unfortunately, you can not derive from System.Xml.XmlNode, because
the two constructors defined are both internal.

I would like to know in which context you are coming across to be
needing

to
derive
a class from XmlNode, and what is it that you are trying to achieve?

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Mahesh Devjibhai Dhola" <md*****@hotmail.com> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
> Hi All,
> I want to make a custom class in c#, which extends System.Xml.XmlNode
> class
> of BCL.
>
> Now in custom class, I have implement abstract methods of XmlNode
> class
> also. Now when I am trying to run the class it gives an error that
> "System.Xml.XmlNode.XmlNode() is inaccessible due to its protection
> level".
>
> This error comes because XmlNode has not any public constructor. I
> found
> XmlNode has two constructor but both are private or friend (i dont
> know
> exactly).
>
> I also found one MSDN article where it says that "Never derive any
> class
> directly from XmlNode" but its just recommendation.
>

(http://msdn.microsoft.com/library/de...-us/cpguide/ht
> ml/cpconextendingdom.asp)
>
> Though, Microsoft has derived some of BCL classes from base XmlNode,
> so
> why
> we can not derive?
> System.Object
> System.Xml.XmlNode
> System.Xml.XmlAttribute
> System.Xml.XmlDocument
> System.Xml.XmlDocumentFragment
> System.Xml.XmlEntity
> System.Xml.XmlLinkedNode
> System.Xml.XmlNotation
>
> So i think there must be some way out of this....
>
> So what to do to create a derived class from XmlNode?
> I heard that many experts are giving their service in news groups. So
> please
> help me out of this.
>
> I have already derived few of my classes from XmlDocument, XmlElement,
> XmlAttribute etc. So i dont want to derive from them but i want to

derive
> the class from XmlNode it self. Please help me to get the answer...
>
> Thanks in Advance.
>
> Thanking you,
> Mahesh Devjibhai Dhola
> "Empower yourself...."
>
>



Nov 16 '05 #5

P: n/a
Thanks a lot Dennis,

1. I read already that MSDN documentation but there is nothing about
XmlNode's constructor. Though i found in dotnet247 site, in which they wrote
that it has 2 private constructor, but i dont believe that it will be
private.
http://www.dotnet247.com/247referenc...Node/__members
I will see it using the .Net Reflector you have mentioned.
Thanks for it.

2. I got your point about the reason not to make it sealed...inheritable

3. I will try using XmlElement. and i will see also Mono's source. I think
this is the last option...

Thanking you very much, Dennis for quick and exact answers....

Mahesh

"Dennis Myrén" <de****@oslokb.no> wrote in message
news:a6******************@news2.e.nsc.no...
Mahesh,
Is there any document which says about its constructors? So i could know...
MSDN provides documentation on the .NET Framework SDK.
System.Xml.XmlNode documentation can be found here:
http://msdn.microsoft.com/library/de...classtopic.asp
Also, great software for viewing .NET assemblies is
Lutz Roeder's .NET Reflector.
You should download that. It is free and can be downloaded from here:
http://www.aisto.com/roeder/dotnet/
What is the intention of microsoft not to make it derivable? If Microsoft
do
not want to make it derivable then it should declare that class as sealed
or
final, not abstract? what is the design aspect behind that?

The reason it is inheritable(not sealed) is it works as a base class
for a number of classes in the system.xml.dll,
including XmlDocument and XmlElement(indirect via XmlLinkedNode).
I do not know though, why the constructurs are internal rather than
protected.
I guess they do now want anyone to derive XmlNode.
Can you give me some way?

Well, most of the core logic is provided by XmlElement i think.
Maybe you could write your own XmlNode and derive from XmlElement.

Otherwise, i am afraid i really do not have any good advice for you.
Other than, of course, create an actual wrapper not inherited from,
but rather utilizing XmlNode internally.
That will request a great deal of code though.
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Mahesh Devjibhai Dhola" <md*****@hotmail.com> wrote in message
news:uU**************@TK2MSFTNGP10.phx.gbl...
Hi Dennis,
Thanking you very much for your reply...
I thought the same thing that i will not be able to derive class from it. Is there any document which says about its constructors? So i could
know...

What is the intention of microsoft not to make it derivable? If Microsoft do
not want to make it derivable then it should declare that class as sealed or
final, not abstract? what is the design aspect behind that?

My real intention is to make my own xml assembly, which in fact is wrapper of all the System.Xml classes with my own added functionalities in each
classes. I want all those classes but it should be mine not Microsoft. So i
am deriving those classes from System.Xml and making my own custom classes with the changed class name, and added my own functioanlities in addition to
available facilities of extended class from System.Xml

Can you give me some way?

Thanks in advance....
"Dennis Myrén" <de****@oslokb.no> wrote in message
news:If******************@news2.e.nsc.no...
Unfortunately, you can not derive from System.Xml.XmlNode, because
the two constructors defined are both internal.

I would like to know in which context you are coming across to be needing
to
derive
a class from XmlNode, and what is it that you are trying to achieve?

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Mahesh Devjibhai Dhola" <md*****@hotmail.com> wrote in message
news:eq**************@TK2MSFTNGP12.phx.gbl...
> Hi All,
> I want to make a custom class in c#, which extends System.Xml.XmlNode
> class
> of BCL.
>
> Now in custom class, I have implement abstract methods of XmlNode

class > also. Now when I am trying to run the class it gives an error that
> "System.Xml.XmlNode.XmlNode() is inaccessible due to its protection
> level".
>
> This error comes because XmlNode has not any public constructor. I
> found
> XmlNode has two constructor but both are private or friend (i dont know > exactly).
>
> I also found one MSDN article where it says that "Never derive any
> class
> directly from XmlNode" but its just recommendation.
>

(http://msdn.microsoft.com/library/de...-us/cpguide/ht
> ml/cpconextendingdom.asp)
>
> Though, Microsoft has derived some of BCL classes from base XmlNode, so > why
> we can not derive?
> System.Object
> System.Xml.XmlNode
> System.Xml.XmlAttribute
> System.Xml.XmlDocument
> System.Xml.XmlDocumentFragment
> System.Xml.XmlEntity
> System.Xml.XmlLinkedNode
> System.Xml.XmlNotation
>
> So i think there must be some way out of this....
>
> So what to do to create a derived class from XmlNode?
> I heard that many experts are giving their service in news groups. So
> please
> help me out of this.
>
> I have already derived few of my classes from XmlDocument, XmlElement, > XmlAttribute etc. So i dont want to derive from them but i want to

derive
> the class from XmlNode it self. Please help me to get the answer...
>
> Thanks in Advance.
>
> Thanking you,
> Mahesh Devjibhai Dhola
> "Empower yourself...."
>
>



Nov 16 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.