473,387 Members | 1,597 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,387 software developers and data experts.

XmlDocument.Load() crashes designer but works anyway?

The following code works when I debug and when I install the software
and run the .exe, but if I try to open the form in the designer (which
causes this code to run), I get an error:

Private Sub LoadTestSettings()
Dim rootPath As String
Dim eventHandler As ValidationEventHandler
rootPath = My.Application.Info.DirectoryPath
eventHandler = New ValidationEventHandler(AddressOf
XmlValidationEventHandler)
_xmlDocument = New XmlDocument()
_xmlDocument.Load(rootPath & "\" & "TestSettings.xml") '-->this is
where the error occurs<--
_xmlDocument.Schemas.Add("http://tempuri.org/TestXmlSchema.xsd",
rootPath & "\" & "TestXmlSchema.xsd")
_xmlDocument.Validate(eventHandler)
End Sub

If I try to open the form in the designer, I get this error:

Could not find file 'C:\Documents and Settings\DanThMan\Local Settings
\Application Data\Microsoft\VisualStudio\8.0\ProjectAssemblies
\gyyihrso01\TestSettings.xml'.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32
bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role,
Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Objec t xmlResolver)
at System.Threading.CompressedStack.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.Exe cuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.CompressedStack.Run(CompressedSta ck
compressedStack, ContextCallback callback, Object state)
at System.Xml.XmlTextReaderImpl.OpenUrl()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader,
Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(String filename)
at Test.DataManager.LoadTestSettings() in C:\Documents and Settings
\DanThMan\My Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 46
at Test.DataManager..ctor() in C:\Documents and Settings\DanThMan\My
Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 33
at Test.DataManager..cctor() in C:\Documents and Settings\DanThMan\My
Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 20

I can't figure out what to specify for the filename in
XmlDocument.Load(string fileName). Does
My.Application.Info.DirectoryPath not work if not in debug mode? If
not, what should I do to get the designer to open?

Thanks for your help,

-Dan

Feb 22 '07 #1
4 1187
change rootpath to application.startuppath

"DanThMan" <da******@cox.netwrote in message
news:11**********************@p10g2000cwp.googlegr oups.com...
The following code works when I debug and when I install the software
and run the .exe, but if I try to open the form in the designer (which
causes this code to run), I get an error:

Private Sub LoadTestSettings()
Dim rootPath As String
Dim eventHandler As ValidationEventHandler
rootPath = My.Application.Info.DirectoryPath
eventHandler = New ValidationEventHandler(AddressOf
XmlValidationEventHandler)
_xmlDocument = New XmlDocument()
_xmlDocument.Load(rootPath & "\" & "TestSettings.xml") '-->this is
where the error occurs<--
_xmlDocument.Schemas.Add("http://tempuri.org/TestXmlSchema.xsd",
rootPath & "\" & "TestXmlSchema.xsd")
_xmlDocument.Validate(eventHandler)
End Sub

If I try to open the form in the designer, I get this error:

Could not find file 'C:\Documents and Settings\DanThMan\Local Settings
\Application Data\Microsoft\VisualStudio\8.0\ProjectAssemblies
\gyyihrso01\TestSettings.xml'.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32
bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role,
Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Objec t xmlResolver)
at System.Threading.CompressedStack.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.Exe cuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.CompressedStack.Run(CompressedSta ck
compressedStack, ContextCallback callback, Object state)
at System.Xml.XmlTextReaderImpl.OpenUrl()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader,
Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(String filename)
at Test.DataManager.LoadTestSettings() in C:\Documents and Settings
\DanThMan\My Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 46
at Test.DataManager..ctor() in C:\Documents and Settings\DanThMan\My
Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 33
at Test.DataManager..cctor() in C:\Documents and Settings\DanThMan\My
Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 20

I can't figure out what to specify for the filename in
XmlDocument.Load(string fileName). Does
My.Application.Info.DirectoryPath not work if not in debug mode? If
not, what should I do to get the designer to open?

Thanks for your help,

-Dan

Feb 23 '07 #2
Thanks, Mark, but I get pretty much the same problem:

Could not find file 'C:\Program Files\Microsoft Visual Studio
8\Common7\IDE\TestSettings.xml'.

-Dan

On Feb 22, 8:44 pm, "Mark Cooney" <m...@mcooney.co.ukwrote:
change rootpath to application.startuppath

"DanThMan" <danth...@cox.netwrote in message

news:11**********************@p10g2000cwp.googlegr oups.com...
The following code works when I debug and when I install the software
and run the .exe, but if I try to open the form in the designer (which
causes this code to run), I get an error:
Private Sub LoadTestSettings()
Dim rootPath As String
Dim eventHandler As ValidationEventHandler
rootPath = My.Application.Info.DirectoryPath
eventHandler = New ValidationEventHandler(AddressOf
XmlValidationEventHandler)
_xmlDocument = New XmlDocument()
_xmlDocument.Load(rootPath & "\" & "TestSettings.xml") '-->this is
where the error occurs<--
_xmlDocument.Schemas.Add("http://tempuri.org/TestXmlSchema.xsd",
rootPath & "\" & "TestXmlSchema.xsd")
_xmlDocument.Validate(eventHandler)
End Sub
If I try to open the form in the designer, I get this error:
Could not find file 'C:\Documents and Settings\DanThMan\Local Settings
\Application Data\Microsoft\VisualStudio\8.0\ProjectAssemblies
\gyyihrso01\TestSettings.xml'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32
bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role,
Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Objec t xmlResolver)
at System.Threading.CompressedStack.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.Exe cuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.CompressedStack.Run(CompressedSta ck
compressedStack, ContextCallback callback, Object state)
at System.Xml.XmlTextReaderImpl.OpenUrl()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader,
Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(String filename)
at Test.DataManager.LoadTestSettings() in C:\Documents and Settings
\DanThMan\My Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 46
at Test.DataManager..ctor() in C:\Documents and Settings\DanThMan\My
Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 33
at Test.DataManager..cctor() in C:\Documents and Settings\DanThMan\My
Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 20
I can't figure out what to specify for the filename in
XmlDocument.Load(string fileName). Does
My.Application.Info.DirectoryPath not work if not in debug mode? If
not, what should I do to get the designer to open?
Thanks for your help,
-Dan

Feb 23 '07 #3
My.Application.Info.DirectoryPath is your debug default directory, change it
too my.application.startuppath
"DanThMan" <da******@cox.netwrote in message
news:11**********************@p10g2000cwp.googlegr oups.com...
The following code works when I debug and when I install the software
and run the .exe, but if I try to open the form in the designer (which
causes this code to run), I get an error:

Private Sub LoadTestSettings()
Dim rootPath As String
Dim eventHandler As ValidationEventHandler
rootPath = My.Application.Info.DirectoryPath
eventHandler = New ValidationEventHandler(AddressOf
XmlValidationEventHandler)
_xmlDocument = New XmlDocument()
_xmlDocument.Load(rootPath & "\" & "TestSettings.xml") '-->this is
where the error occurs<--
_xmlDocument.Schemas.Add("http://tempuri.org/TestXmlSchema.xsd",
rootPath & "\" & "TestXmlSchema.xsd")
_xmlDocument.Validate(eventHandler)
End Sub

If I try to open the form in the designer, I get this error:

Could not find file 'C:\Documents and Settings\DanThMan\Local Settings
\Application Data\Microsoft\VisualStudio\8.0\ProjectAssemblies
\gyyihrso01\TestSettings.xml'.

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32
bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role,
Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Objec t xmlResolver)
at System.Threading.CompressedStack.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.Exe cuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.CompressedStack.Run(CompressedSta ck
compressedStack, ContextCallback callback, Object state)
at System.Xml.XmlTextReaderImpl.OpenUrl()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader,
Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(String filename)
at Test.DataManager.LoadTestSettings() in C:\Documents and Settings
\DanThMan\My Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 46
at Test.DataManager..ctor() in C:\Documents and Settings\DanThMan\My
Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 33
at Test.DataManager..cctor() in C:\Documents and Settings\DanThMan\My
Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 20

I can't figure out what to specify for the filename in
XmlDocument.Load(string fileName). Does
My.Application.Info.DirectoryPath not work if not in debug mode? If
not, what should I do to get the designer to open?

Thanks for your help,

-Dan

Feb 24 '07 #4
sorry read wrong posting

"DanThMan" <da******@cox.netwrote in message
news:11*********************@m58g2000cwm.googlegro ups.com...
Thanks, Mark, but I get pretty much the same problem:

Could not find file 'C:\Program Files\Microsoft Visual Studio
8\Common7\IDE\TestSettings.xml'.

-Dan

On Feb 22, 8:44 pm, "Mark Cooney" <m...@mcooney.co.ukwrote:
>change rootpath to application.startuppath

"DanThMan" <danth...@cox.netwrote in message

news:11**********************@p10g2000cwp.googleg roups.com...
The following code works when I debug and when I install the software
and run the .exe, but if I try to open the form in the designer (which
causes this code to run), I get an error:
Private Sub LoadTestSettings()
Dim rootPath As String
Dim eventHandler As ValidationEventHandler
rootPath = My.Application.Info.DirectoryPath
eventHandler = New ValidationEventHandler(AddressOf
XmlValidationEventHandler)
_xmlDocument = New XmlDocument()
_xmlDocument.Load(rootPath & "\" & "TestSettings.xml") '-->this is
where the error occurs<--
_xmlDocument.Schemas.Add("http://tempuri.org/TestXmlSchema.xsd",
rootPath & "\" & "TestXmlSchema.xsd")
_xmlDocument.Validate(eventHandler)
End Sub
If I try to open the form in the designer, I get this error:
Could not find file 'C:\Documents and Settings\DanThMan\Local Settings
\Application Data\Microsoft\VisualStudio\8.0\ProjectAssemblies
\gyyihrso01\TestSettings.xml'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess
access, Int32 rights, Boolean useRights, FileShare share, Int32
bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String
msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess
access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role,
Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Objec t xmlResolver)
at System.Threading.CompressedStack.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.Exe cuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.CompressedStack.Run(CompressedSta ck
compressedStack, ContextCallback callback, Object state)
at System.Xml.XmlTextReaderImpl.OpenUrl()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader,
Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at System.Xml.XmlDocument.Load(String filename)
at Test.DataManager.LoadTestSettings() in C:\Documents and Settings
\DanThMan\My Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 46
at Test.DataManager..ctor() in C:\Documents and Settings\DanThMan\My
Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 33
at Test.DataManager..cctor() in C:\Documents and Settings\DanThMan\My
Documents\Projects\Test\Development\App Code\Test\Test
\DataManager.vb:line 20
I can't figure out what to specify for the filename in
XmlDocument.Load(string fileName). Does
My.Application.Info.DirectoryPath not work if not in debug mode? If
not, what should I do to get the designer to open?
Thanks for your help,
-Dan


Feb 24 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Manfred Braun | last post by:
Hi All, I am trying to access xml-files in the internet from my intranet-page. Making XmlDocument.Load() calls internally works fine, but not so to the internet. I think the calls are failing,...
2
by: Gustaf Liljegren | last post by:
I need to merge several XML files into one large. All of them has a DOCTYPE tag, but the SYSTEM identifier points to a DTD that doesn't exist. (I use the PUBLIC identifier with catalog files, so...
2
by: Graham Pengelly | last post by:
Hi I am trying to transform on System.Xml.XmlDocument into another using XslTransform without writing the object out to a file. I am guessing it should work something like this... public...
1
by: Peter Nofelt | last post by:
Hey All, I'm running into this issue with parsing through an xml document by tag name. Below is an example xml document: File Name: things.xml <things> <people> <name>Peter</name>
0
by: delphiconsultingguy | last post by:
Hi all, Spent WAAAYYY too much time trying to figure this out because there's not many good examples out there, so in the interest of sparing y'all from suff'rin same, I've pasted it into...
2
by: supercodepoet | last post by:
I have cXml document I want to load to parse. The document has a DOCTYPE element that points to an external dtd via http. When the document loads it trys a web request which I am assuming is to...
4
by: DanThMan | last post by:
The following code works when I debug and when I install the software and run the .exe, but if I try to open the form in the designer (which causes this code to run), I get an error: Private Sub...
4
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... We've got a lot of places in our code where we read relatively small xml user preference blocks. Currently that's creating a new XmlDocument in every spot. I was thinking we might see...
1
by: =?Utf-8?B?RGF2aWRHQg==?= | last post by:
OK, so I've created and loaded an XMLDocument object. But how do I go about using it? Specifically, how do I: 1) move to the first node (I assume I start on it when I load the XML?) 2) move to...
3
by: =?Utf-8?B?RWQgS3JhbWVy?= | last post by:
I thought this might be useful for someone... I was doing a little work earlier using an Xmldocument class to create & maintain a minor store of data in Xml format. I'd gotten the whole thing...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.