Question

I am trying to open an InfoPath 2007 file programmatically from a Windows service, but I get the following error:

System.Runtime.InteropServices.COMException (0x80043000): InfoPath cannot open the following file: C:\path\datafile.xml. Not enough storage is available to complete this operation.

This file opens correctly in the InfoPath designer. It also runs programmatically as a WinForms application. But when you try to run as a Windows service, it blows up.

I have consulted the mighty Google. The two main results that come back are either malformed XML (not the cause, as the form opens correctly manually) or something to do with trying to access a database (which I am not doing).

Does anyone know how to do this? Are there permissions I need to set on the service?

Update:

As per Anders request, here is the code. Note that this may not be the exact code I was working with 6 months ago when I originally posted the question. We have since moved on to using XtraReports, as it seems much easier to work with and has less of these cryptic errors. I would, however, like to resolve this question for anyone else who comes along and may need an answer.

Microsoft.Office.Interop.InfoPath.Application infoApp = new Microsoft.Office.Interop.InfoPath.Application();
try
{
    Microsoft.Office.Interop.InfoPath.XDocument xDoc = null;
    xDoc = infoApp.XDocuments.Open(fileName, (int)Microsoft.Office.Interop.InfoPath.XdDocumentVersionMode.xdUseExistingVersion);

    xDoc.PrintOut();
    infoApp.XDocuments.Close(0);
}
catch (Exception ex)
{
    //handle error here
}
finally
{
    try
    {
        if (infoApp != null)
            infoApp.Quit(false);
    }
    catch { }
}
Was it helpful?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top