D
DanThMan
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(Object xmlResolver)
at System.Threading.CompressedStack.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.CompressedStack.Run(CompressedStack
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
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(Object xmlResolver)
at System.Threading.CompressedStack.runTryCode(Object userData)
at
System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode
code, CleanupCode backoutCode, Object userData)
at System.Threading.CompressedStack.Run(CompressedStack
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