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

writer error

P: n/a
Hello,
I declare it in a public function inside a class:
XmlTextWriter xml_writer=null;
xml_writer=new XmlTextWriter();

and get this error:

System.Xml.Writer.XmlTextWriter()' is inaccessible due to its protection
level

Could someone tell me why (in c#) it happens?
Thanks a lot!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a


juli jul wrote:

I declare it in a public function inside a class:
XmlTextWriter xml_writer=null;
xml_writer=new XmlTextWriter();

and get this error:

System.Xml.Writer.XmlTextWriter()' is inaccessible due to its protection
level


You need to have an argument or two for the constructor e.g.
XmlTextWriter xmlWriter = new XmlTextWriter(fileName, encoding);
or
XmlTextWriter xmlWriter = new XmlTextWriter(stream, encoding);
or
XmlTextWriter xmlWriter = new XmlTextWriter(textWriter);

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 12 '05 #2

P: n/a
juli jul wrote:
I declare it in a public function inside a class:
XmlTextWriter xml_writer=null;
xml_writer=new XmlTextWriter();

and get this error:

System.Xml.Writer.XmlTextWriter()' is inaccessible due to its protection
level

Could someone tell me why (in c#) it happens?


Because XmlTextReader class has no public constructor with no arguments.
See available constructors at
http://msdn.microsoft.com/library/de...sctorTopic.asp

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #3

P: n/a
Sorry,please ignore this question - I forgot to add a file name to write
to.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.