It is just a general error and could be anything in your code.
Not doing much in c sharp, is the number 3 equal to a dialog mode? I would have used something like.
We are in the process of porting this over from VB. The logic works fine in the vb version, but in c# this specific ps method fails. It doesn't seem to matter what params I pass in.
That error usually means some required condition current document state required for the function does not exist so the function is not possible in the document current state. There may be nothing targeted or the wrong type of layer is targeted or to many layers are currently targeted, A selection or paths is required and none exists etc
I wonder if you have tried creating the function again in Photoshop and then using the scriptlistener output to convert?