Hi everyone,

I am sorry if post this question in the wrong place.

I am using C#, Continuum to intercept user click buttons in Modal Dialog Window by the following code:

In Main:
Application GpApp;
Type t = Type.GetTypeFromProgID("Dynamics.Application", false);
GpApp = (Application)Activator.CreateInstance(t);
GpApp.RegisterFocusTrigger("window 'PM_Transaction_Entry' of form 'PM_Transaction_Entry", focusType, attachType, new ModalDialogHandler(), "action");

In ModalDialogHandler class:
class ModalDialogHandler
        public void action(int dialog_type, string prompt, string control_1, string control_2, string control_3, int answer)
            System.Console.WriteLine("Answer: " + answer.ToString());

I always get error "Specified cast is not valid." when I run this code.

Thank you in advance, I appreciate all you answers.


Edit 9/16/2015: View the main article for this error here 

I am new to eConnect/GP and am using version 9.  I am attempting to update purchase orders in GP once they have been received.  This works fine in most cases, but one thing I've noticed is that if you simulatneously send up two line items (taPopRcptLineInsert) from the same order that have identical item numbers, even though they have different line numbers (RCPTLNNM), eConnect issues the error "Input variable contains a duplicate document (POPRCTNM)".  If the items are different there is no problem.  GP does allow users to add the same items with the same item number on separate detail lines for a purchase order, so I'm not sure why eConnect would have a problem with this.  Any ideas?

Table Definition Quick Links
All Tables
SOP Tables
RM Tables
GL Tables
POP Tables
HR Tables
PM Tables
UPR Tables
IV Tables
Olympic Tables