I am trying to read an XML file with RAB builder in vb.Net, the problem is that when I set the instruction ’ m_xmlr.Read()’ the program jumps to the catch instruction and I get the following error.
This is my program code!
Imports System.Xml
Dim m_xmlr As XmlTextReader
Sub Read_XML()
Try
’ Create the XML Reader
m_xmlr = New XmlTextReader(xmlFile)
’ Read the XML file
m_xmlr.Read()
’ The rest of the code is not implemented…
…
’
Catch ex As Exception
GTPUMessageBox.Show(Nothing, Nothing, ex.ToString, “Debug”, System.Windows.Forms.MessageBoxIcon.Exclamation, System.Windows.Forms.MessageBoxButtons.OK)
End Try
I found this sample on MSDN, which shows how to configure the XmlReader to be able to access a file on the web (which I know is not what you are doing) ;
’ Supply the credentials necessary to access the Web server.
Dim resolver as XmlUrlResolver = new XmlUrlResolver()
resolver.Credentials = CredentialCache.DefaultCredentials
reader.XmlResolver = resolver
"
From what I could understand the reader also tries to resolve references to Schemas, specified in the XML file over the web.
Its a long shot, but try to set the XmlTextReader.Resolver to Nothing/Null, and make sure your file path is valid so its not mistaken for a resource on the web for some strange reason.
the FlexPendant device itself is a separate computer compared to the IRC5 controller.
So when you write code like “new FileStream(path, FileMode.Open);” the path specified can not be a path on the controller file system.
Basically you have to get the file from the controller to the FlexPendant using the Controller.FileSystem class which provides FTP-like functionality.
Then you can open the file on the FlexPendant.
Example:
FileStream fs = null;
if (this._Controller.IsVirtual)
{
fs = new FileStream(this._HomeDir + "/mpLocation.mod", FileMode.Open);
}
else
{
// on the real controller, get the file first
FileSystem fsys = this._Controller.FileSystem;
fsys.RemoteDirectory = this._HomeDir;
fsys.GetFile("mpLocation.mod", "/Temp/" + "mpLocation.mod");
fs = new FileStream("/Temp/" + "mpLocation.mod", FileMode.Open);
}
There may be a better way to handle the VC/RC issue than the one in my example. I’ll check that and come back.
I want to log the error in to the “Event log”.
I know the list of errors in my applications.
I would like to create a XML file to list out my all the application errors.
While running my applications any error occurs, I would like to log in to the event log.
Which will be helpful for me to trace what happened in the process.
Guide me. Thank you.