I am using currentview.export to export the current view of the form to a pdf file. I have been having mixed results. Sometimes it works, other times I get an error. The error I'm getting at the moment, and displaying in a message box is
"InfoPath has encountered an error. The operation failed."
"InfoPath cannot export the form."
"The process cannot access the file because it is being used by another process."
The filename I'm exporting to is C:\InfoPath\TestForm.pdf. I thought at first I encountered a filename length limitation of some sort, because it was failing every time I exported a file whose name was > 40 characters. Now, however, I'm getting the error on short file names.
I have created a very simple form with nothing on it except a text box and a few buttons. I can debug the code and catch the error in the code:
this.CurrentView.Export(xpsFormName, ExportFormat.Pdf);
The xpsFormName variable shows that it has a valid filename. Overall, it should be pretty simple. I'm just wondering why, at times (now more often) I'm getting this error. I'm also programmatically writing the XML file to the same folder and that is working just fine. It appears to be something unique to the export as PDF function (yes, I have the extension installed).
Full trust is selected, the form is digitially signed and it works sometimes.
Could it be that it's having a problem loading the assembly that provides the conversion?