In a VSTO Excel addin the code:
Dim XMLDoc As XElement = XElement.Load("XMLFile1.xml")
generates a FileNotFound
error with the message ("Could not find file 'C:\Users\doug\Documents\XMLFile1.xml'.") It's looking in the My Documents folder but the XML file is located in the VS Projects folder for that project.
I have set the XML file's "Copy to Output Directory" property to "Copy always". When I change the code to include the full path to the XML file the code works.
Also, if I include the above code in a Windows Console or other type of project it runs correctly. I'm only getting it in the Excel Addin. The above is true for VSTO 2008/Excel 2003 and VSTO 2010/Excel 2010.