I have a MS Access Database that has a button on it that is supposed to run a tool that I wrote. The tool works. The Access DB works. The VBA to run the tool works.
However, there is an issue when running the tool from VBA. It always crashes when trying to load XML configuration data. I tested this by checking my Error Reporting tool (Control Panel -> Administrative Tools -> Event Viewer). I also wrote a second version of my tool which has all of the XML data hard-coded into it.
I am wondering if there is a known reason for this to occur, and if there is a workable solution for getting around this error. Hard-coding all of my configuration data is not really an ideal solution, as the configuration data needs to be modifiable without having to recompile the entire project and push out an update.
Information:
- MS Access 2010 with Visual Basic for Applications (using Shell for application calling)
- C# application with XML configuration data using references (IO, Linq, Xml.Linq, Data.OleDb, Globalization)
Thanks for any assistance you may be able to offer.
Per request, here is the code I use to run the application:
Dim hProcess As Long
Dim myPath As String
dim myFile As String
myPath = Environ("ProgramFiles(x86)" & "\mytool\"
myFile = "mytool.exe"
hProcess = Shell( myPath & myFile, vbNormalFocus )
The application is a WinForms application that allows the user to map column names in a csv to fields in access. The only actual issue is the part where it attempts to load the XML configuration data:
XDocument xDoc = XDocument.Load(Environment.CurrentDirectory + "\\config.xml");
Again, if I hard-code the configuration data into the application itself, there is no issue at all when running the application. However, if I attempt to load the XML configuration data, it gives an Error Event in the Event Viewer stating that there was an unhandled exception when loading the XML file. If I run the application outside of the VBA Shell call, it runs fine and can load the XML file. It only ever crashes when trying to load the XML from VBA Shell.
System.IO.FileNotFoundExceptionhappens even if the path points to and the file is located at:C:\temp\config.xml?