Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2007

Tip: Looking for answers? Try searching our database.

XmlDocument.Load() crashes designer but works anyway?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DanThMan - 22 Feb 2007 23:28 GMT
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
Mark Cooney - 23 Feb 2007 04:44 GMT
change rootpath to application.startuppath

> 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
[quoted text clipped - 62 lines]
>
> -Dan
DanThMan - 23 Feb 2007 17:48 GMT
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

> change rootpath to application.startuppath
>
[quoted text clipped - 64 lines]
>
> > -Dan
Mark Cooney - 24 Feb 2007 07:46 GMT
sorry read wrong posting

> Thanks, Mark, but I get pretty much the same problem:
>
[quoted text clipped - 71 lines]
>>
>> > -Dan
Mark Cooney - 24 Feb 2007 07:45 GMT
My.Application.Info.DirectoryPath is your debug default directory, change it
too my.application.startuppath

> 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
[quoted text clipped - 62 lines]
>
> -Dan

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.