Click here to Skip to main content
16,005,178 members
Home / Discussions / C#
   

C#

 
QuestionRe: how to trap/manage windows messege(s) in vc# 2005 ? Pin
Vikram A Punathambekar16-Apr-07 19:49
Vikram A Punathambekar16-Apr-07 19:49 
QuestionCrc32 Help Pin
teejayem16-Apr-07 16:00
teejayem16-Apr-07 16:00 
AnswerRe: Crc32 Help Pin
Luc Pattyn17-Apr-07 0:23
sitebuilderLuc Pattyn17-Apr-07 0:23 
QuestionHow can I get the Mouse POsition on click? Pin
Khoramdin16-Apr-07 15:25
Khoramdin16-Apr-07 15:25 
AnswerRe: How can I get the Mouse POsition on click? Pin
kkun16-Apr-07 15:33
kkun16-Apr-07 15:33 
QuestionRe: How can I get the Mouse POsition on click? Pin
Khoramdin16-Apr-07 20:04
Khoramdin16-Apr-07 20:04 
AnswerRe: How can I get the Mouse POsition on click? Pin
kkun16-Apr-07 21:28
kkun16-Apr-07 21:28 
QuestionXML reader issues.... Pin
Super Lloyd16-Apr-07 14:32
Super Lloyd16-Apr-07 14:32 
I have a XML document (not of my making) which starts like that:
==========
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
........................
==========

I read it with code such as:
Stream s = .....
using(XmlTextReader xtr = new XmlTextReader(s))
{
xtr.MoveToContent(); // <<== problem here
xr.Read();
.....
}

The problem that I have is, if the user's computer is not connected to a network, the xtr.MoveToContent() fail with the following exception:
=========
Stack :
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.DtdParserProxy_PushExternalSubset
(String systemId, String publicId)
at
System.Xml.XmlTextReaderImpl.DtdParserProxy.System.Xml.IDtdParserAdapter
.PushExternalSubset(String systemId, String publicId)
at System.Xml.DtdParser.ParseExternalSubset()
at System.Xml.DtdParser.ParseInDocumentDtd(Boolean
saveInternalSubset)
at System.Xml.DtdParser.Parse(Boolean saveInternalSubset)
at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlReader.MoveToContent()
-------- Caused by Exception --------
Exception : System.Net.WebException
Message : Unable to connect to the remote server
Source : System
Help :
Stack :
at System.Net.HttpWebRequest.GetResponse()
at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri,
ICredentials credentials)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String
role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenStream(Uri uri)
at System.Xml.XmlTextReaderImpl.DtdParserProxy_PushExternalSubset
(String systemId, String publicId)

-------- Caused by Exception --------
Exception : System.Net.Sockets.SocketException
Message : A socket operation was attempted to an unreachable host
Source : System
Help :
Stack :
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean
connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress&
address, ConnectSocketState state, IAsyncResult asyncResult, Int32
timeout, Exception& exception)

=========

But I absolutely don't care about the DTD, in fact there is nothing at this URL.
I try many various settings, but I can't see a way to get around this problem other than a try/catch.

The problem is: it is easy to forget to put try/catch around the first XML read.
Is there any better way?
AnswerRe: XML reader issues.... [modified] Pin
Patrick Klug16-Apr-07 15:08
Patrick Klug16-Apr-07 15:08 
QuestionXml - DTD processing Pin
Patrick Klug16-Apr-07 14:23
Patrick Klug16-Apr-07 14:23 
AnswerRe: Xml - DTD processing Pin
Russell Jones16-Apr-07 21:08
Russell Jones16-Apr-07 21:08 
AnswerRe: Xml - DTD processing Pin
Super Lloyd16-Apr-07 21:08
Super Lloyd16-Apr-07 21:08 
Questioncryptography and Steganography ... Pin
Software_Specialist16-Apr-07 13:10
Software_Specialist16-Apr-07 13:10 
JokeRe: cryptography and Steganography ... Pin
Luc Pattyn16-Apr-07 13:29
sitebuilderLuc Pattyn16-Apr-07 13:29 
GeneralRe: cryptography and Steganography ... Pin
Software_Specialist17-Apr-07 5:33
Software_Specialist17-Apr-07 5:33 
AnswerRe: cryptography and Steganography ... Pin
sujithkumarsl16-Apr-07 19:56
sujithkumarsl16-Apr-07 19:56 
QuestionComboBox values from lookups table Pin
sailchris2216-Apr-07 12:48
sailchris2216-Apr-07 12:48 
GeneralRe: ComboBox values from lookups table Pin
andre_swnpl16-Apr-07 19:26
andre_swnpl16-Apr-07 19:26 
QuestionA really stupid / simple re. generics and their base type Pin
malharone16-Apr-07 10:38
malharone16-Apr-07 10:38 
AnswerRe: A really stupid / simple re. generics and their base type Pin
Christian Graus16-Apr-07 16:12
protectorChristian Graus16-Apr-07 16:12 
GeneralRe: A really stupid / simple re. generics and their base type Pin
malharone26-Apr-07 20:27
malharone26-Apr-07 20:27 
GeneralRe: A really stupid / simple re. generics and their base type Pin
Christian Graus26-Apr-07 22:11
protectorChristian Graus26-Apr-07 22:11 
QuestionHow to Render a mcms posting page in snother page Pin
MyRunner16-Apr-07 10:22
MyRunner16-Apr-07 10:22 
QuestionCasting in C# Pin
BlitzPackage16-Apr-07 9:29
BlitzPackage16-Apr-07 9:29 
AnswerRe: Casting in C# Pin
MoustafaS16-Apr-07 9:41
MoustafaS16-Apr-07 9:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.