| | | StrataFrame VIP
       
Group: StrataFrame Users Last Login: Today @ 3:11:51 PM Posts: 1,148, Visits: 2,831 |
| I'm attempting to use XMLBasics to store some startup options and am having trouble getting it to work. I keep getting an error whenever I try to open it encrypted when it has no data in it yet. A couple of things are confusing the heck out of me. First, when I look at the source code (that I have), there is no OpenXMLFileBase method in XMLBasics. I'm thinking y'all have changed this one lately. Second, it appears to be loosing the a temp file (the file listed as not being found is not the file I'm opening) during the encryption process. If I turn off encryption, it works fine.
Here's the code and the exception:
Here is the function:
Private Function GetDataSet() As DataSet
'-- Establish a return variable
Dim retSet As DataSet
'-- Build the full path to the file
Dim fullPath As String = Path.Combine(Me.GetPath(), Me.XmlFileName)
'-- Open the file and get the data set
retSet = XmlBasics.OpenXmlFile(Me.GetCurrentVersion() _
, Me.TableName _
, fullPath _
, Me.GetXmlStructure() _
, True)
'--return the store data table
Return retSet
End Function
And the exception:
FileNotFoundException
Could not find file 'C:\Documents and Settings\greg\Local Settings\Temp\glu221xf.tmp'.
Source : mscorlib
Stack Trace:
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.XmlTextReader.Read()
at System.Xml.XmlReader.MoveToContent()
at System.Data.DataSet.ReadXml(XmlReader reader, XmlReadMode mode, Boolean denyResolving)
at System.Data.DataSet.ReadXml(String fileName, XmlReadMode mode)
at MicroFour.StrataFrame.Xml.XmlBasics.OpenXMLFileBase(String CurrentVersion, String TableName, String PathAndFileName, List`1 ColumnStructure)
at MicroFour.StrataFrame.Xml.XmlBasics.OpenXmlFile(String Version, String TableName, String PathAndFileName, List`1 ColumnStructure, Boolean DecryptFile)
at ConnestionStringFileManager.ConnectionStrings.OpenStore() in E:\SacredSpaceSoftware\ConnestionStringFileManager\ConnectionStrings.vb:line 296
at ConnestionStringFileManager.ConnectionStrings.GetData() in E:\SacredSpaceSoftware\ConnestionStringFileManager\ConnectionStrings.vb:line 323
at ConnestionStringFileManager.ConnectionStrings.LoadStore() in E:\SacredSpaceSoftware\ConnestionStringFileManager\ConnectionStrings.vb:line 250
at ConnestionStringFileManager.ConnectionStrings.Load() in E:\SacredSpaceSoftware\ConnestionStringFileManager\ConnectionStrings.vb:line 139
at ConnestionStringFileManager.MainForm.cmdLoad_Click(Object sender, EventArgs e) in E:\SacredSpaceSoftware\ConnestionStringFileManager\MainForm.vb:line 46
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativewindow.WndProc(Message& m)
at System.Windows.Forms.Nativewindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Today @ 11:54:01 AM Posts: 4,104, Visits: 4,177 |
| | First, if the file already exists on disk asn was NOT created by the OpenXmlFile (or WriteXmlFile), the you are going to get an error. OpenXmlFile will create the file if it does not exist and it stores two tables within the data set. Have you looked at this sample yet: http://forum.strataframe.net/FindPost13102.aspx ? It should give you a better idea of how to open and XmlFile through XmlBasics and to update the structure etc. In this example, does the tmp file already exist? Also, what is in your path? If you would like, you could create me a quick sample and I will change your code to show you how to correct your error.  |
| | | | StrataFrame VIP
       
Group: StrataFrame Users Last Login: Today @ 3:11:51 PM Posts: 1,148, Visits: 2,831 |
| Yep, I've looked at that sample. In fact, after that post and what I learned there, I've used XMLBasics a number of times, but not encrypted.
If you take a look at the code I posted, you'll see what I'm doing. If I include the flag to decrypt, it bombs. If I don't include that flag, it works.
This bombs with the exception:
[codesnippet]retSet = XmlBasics.OpenXmlFile(Me.GetCurrentVersion(),Me.TableName, fullPath, Me.GetXmlStructure() , True)/codesnippet]
This works:
[codesnippet]retSet = XmlBasics.OpenXmlFile(Me.GetCurrentVersion(),Me.TableName, fullPath, Me.GetXmlStructure() )/codesnippet]
The file it can't find isn't mine. My path is something like e:\samples\encryptedxml\bin\debug\exml.dat. |
| | | | StrataFrame VIP
       
Group: StrataFrame Users Last Login: Today @ 3:11:51 PM Posts: 1,148, Visits: 2,831 |
| OK, it's official...I'm loosing my mind.     
I created a simple sample to demonstrate the problem...except no problem.
So I imported the class causing the problem and used it...except no problem.
So I went back the to original project, and added a message box, to make sure I had the path right. Then I got rid of some encryption I was using. It worked. So I started backwards to find out where the problem showed up....except it didn't. It works now. I have no idea what happened, but it works now. Maybe it was just your esteemed presence??? |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Today @ 11:54:01 AM Posts: 4,104, Visits: 4,177 |
| Maybe it was just your esteemed presence???  ROFL...that's good, because I obviously could not reproduce this on my side as it kept working....so I was in the scratching head phase  |
| |
|
|