Unable to show modal form within this context

I’m trying to set up a service to pick up files in a specified folder and convert them to PDFs. Im running PDFCreator 1.5.1 on windows Server 2008 r2. however I keep getting the following error:


"System.Runtime.InteropServices.COMException was unhandled
  ErrorCode=-2146827883
  Message=“Unable to show modal form within this context”
  Source=“PDFCreator”
  StackTrace:
       at PDFCreator.clsPDFCreatorClass.cPrintFile(String filename)
       at pdfCreatorFolderWatcher.Service1.FileSystemWatcher1_Created(Object sender, FileSystemEventArgs e) in Service1.vb:line 64
       at System.IO.FileSystemWatcher.OnCreated(FileSystemEventArgs e)
       at System.IO.FileSystemWatcher.NotifyFileSystemEventArgs(Int32 action, String name)
       at System.IO.FileSystemWatcher.CompletionStatusChanged(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* overlappedPointer)
       at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)"

The code in question is: 

"Private Sub FileSystemWatcher1_Created(ByVal sender As System.Object, ByVal e As System.IO.FileSystemEventArgs) Handles FileSystemWatcher1.Created
        If e.ChangeType = IO.WatcherChangeTypes.Created Then
            With _PDFCreator
                .cDefaultPrinter = “PDFCreator”
                .cPrintFile(e.FullPath)
                .cPrinterStop = False
            End With
        End If
    End Sub"

I’ve tried adding .cVisible=False in an attempt to suppress any pop ups, no luck. Any help would be greatly appricated

Hi, do you have autosave enabled?
Using autosave should disable all pop-ups.
You can also have a look at the COM folder located in your PDFCreator path, there are some examples there.

regards,

Robin


Yes autosave is enabled, I originally used the COM examples to build this program. I think it has something to do with the printing status dialog opened when the file is added to the print queue.

If it helps at all in debugger I noticed that despite me preforming “With _PDFCreator.cDefaultPrinter = “PDFCreator”” cDefaultPrinter is returning " {Unable to show modal form within this context} "

Turns out it was a permission issue, running the service with Administrator permissions rather than as a local service solved the problem. after some fiddling I figured out that the user area running the service needs local activation permissions on the DCOM config system as well as the file systems being used. I hope this helps anyone with this problem