473,378 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Problem in deriving class from XmlNode BCL class

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
5 2116
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: JustSomeGuy | last post by:
I need to write an new class derived from the list class. This class stores data in the list to the disk if an object that is added to the list is over 1K in size. What methods of the std stl...
2
by: Julian | last post by:
I would like to have output from my program to be written to cout as well as a file. (actually, i want several other output options but this should explain my problem in the simplest way). I have...
2
by: Bonj | last post by:
Hello Can anyone assist with the following class hierarcy problem? I have a series of window classes, the object model currently being as such: Window / | \ / | \...
7
by: Microsoft News | last post by:
Hi all. Does id() xpath function work in System.XML? I have built dtd, schema, xdr for a simple xml which includes attributes definded as ID and IDREFS. Validation is occurring properly for all...
3
by: Mahesh Devjibhai Dhola | last post by:
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...
8
by: hex | last post by:
Hi I make a class "MyClass" and this clas implements the Interface ICloneable. I want when I instance an object from MyClass and I call obj.Clone() it returns an object of MyClass type. for...
7
by: erin.sebastian | last post by:
Hello Everyone, This is my first attempt at coding using an abstract class and i am getting an error i can't figure out. Here is the back ground. I have a project that contains an abstract...
1
by: John Wilhelm | last post by:
I'm having a problem in by VB.net 2005 application. When i try to get a node from my app.config file the node come back with "nothing". The xmldocment loads OK, but I can't retrive a node. The...
0
by: SpaceMarine | last post by:
hello, i am working on a web application w/ UserControls. some of my controls use the same functionality (an Event they all raise) so it seemed sensible to place them into a custom base class,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.