Site Search:
Sign in | Join | Help

Why error when trying to "RegisterFocusTrigger()"?

Last post 07-28-2009 11:27 AM by das974. 20 replies.
Page 1 of 2 (21 items) 1 2 Next >
Sort Posts: Previous Next
  • 04-02-2008 8:55 PM

    Why error when trying to "RegisterFocusTrigger()"?

     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.

    Tola 

    • Post Points: 0
  • 04-03-2008 6:42 PM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

    Hi everyone,

    Regarding to my problem, I have checked:

    Register for COM interop  (in Project -> Properties -> Build )

    It worked very well. But I still not understand why.

    Anyone could explain me about this matter?

     

    Tola 

    • Post Points: 0
  • 05-17-2009 2:02 PM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

    Dear Sir

     i am facing the Same error you have please advise me what to do.

     

    I build my solution and I add the DLL in this path: C:\Program Files\Microsoft Dynamics\GP\AddIns

     

    Please find hereunder the code I wrote:

    using System;using System.Collections.Generic;using System.Text;using Microsoft.Dexterity.Bridge;using Microsoft.Dexterity.Applications;using ContinuumAPIProjectCSharp; namespace HowToTestContinuumAPI{    public class GPAddIn : IDexterityAddIn    {        // IDexterityAddIn interface        public static Dynamics.Application GPAPP;        public GPCallbackClass GPCallBack = new GPCallbackClass();                public void Initialize()        {                //Dynamics.DIALOG_RESPONSE                GPAPP.RegisterFocusTrigger("window 'IV_Transaction_Lot_Numbers' of form 'IV_Transaction_Entry'",            8, 2, GPCallBack, "POP_Lot_Entry_Dialogs");                }        // focus_type - An integer that identifies which focus event causes the trigger to run.        // PRE 0 Fields, windows, forms and scrolling windows        // CHANGE 1 Fields and scrolling windows        // POST 2 Fields, windows, forms and scrolling windows        // PRINT 3 Windows        // ACTIVATE 4 Windows        // FILL 5 Scrolling windows        // INSERT 6 Scrolling windows        // DELETE 7 Scrolling windows        // MODAL DIALOG 8 Modal dialog (dialogs generated by error, warning, ask()        //or getstring() sanScript commands)        enum focus_type        {            PRE = 0, CHANGE, POST, PRINT, ACTIVATE, FILL, INSERT,            DELETE, MODAL_DIALOG = 0        }        //attach_type - An integer indicating when the focus trigger runs relative        //to the original focus event:        //1 Trigger runs before the focus event.        //2 Trigger runs after the focus event.        enum attach_type { Before = 1, After }    }}   

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

      using System;using System.Collections.Generic;using System.Text; namespace ContinuumAPIProjectCSharp{    public class GPCallbackClass    {        public GPCallbackClass()        {        }        public void POP_Lot_Entry_Dialogs(int dialogType, string prompt, ref string        control1, ref string control2, ref string control3, ref int answer)        {            if (dialogType == 0 && prompt == "Are you sure you want to remove all lot numbers?")            {                answer = 0;                HowToTestContinuumAPI.GPAddIn.GPAPP.StopProcessing();            }        }    }}

     

    • Post Points: 0
  • 05-17-2009 2:07 PM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

    Dear Sir

    i did your solution but i have this error:

    Error 1 Cannot register assembly "D:\Edita\NetProjects\DynamicsGPAddin1\HowToTestContinuumAPI\bin\Debug\HowToTestContinuumAPI.dll". The specified module could not be found. (Exception from HRESULT: 0x8007007E) HowToTestContinuumAPI

     

    please advise

    • Post Points: 0
  • 05-17-2009 2:25 PM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

    The correct code should be like this.

     GPAPP.RegisterFocusTrigger("window 'IV_Transaction_Lot_Numbers' of form 'IV_Transaction_Entry'",            8, 2,new GPCallBack(), "POP_Lot_Entry_Dialogs");

    • Post Points: 0
  • 05-17-2009 2:28 PM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

     

    thank you for your reply but did you see my last post, i already did that and i still having the same error.

    please advise me more

    • Post Points: 0
  • 05-17-2009 2:31 PM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

     You got "... Error 1 ..."

    I think it cause by circular dependency.

    In Class GPCallbackClass you used  Class GPAddIn used GPCallbackClass used HowToTestContinuumAPI.GPAddIn.GPAPP.StopProcessing();

    • Post Points: 0
  • 05-17-2009 2:36 PM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

    you mean like this :

    GPAddIn.GPAPP.StopProcessing();

    but i am still facingthis problem while i am building my solution :

    "Error 1 Cannot register assembly "D:\Edita\NetProjects\DynamicsGPAddin1\HowToTestContinuumAPI\bin\Debug\HowToTestContinuumAPI.dll". The specified module could not be found. (Exception from HRESULT: 0x8007007E) HowToTestContinuumAPI
    "

    • Post Points: 0
  • 05-17-2009 2:37 PM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

    this step:

    Register for COM interop  (in Project -> Properties -> Build )

     

    tell me more about it.

     

    please

    • Post Points: 0
  • 05-17-2009 3:18 PM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

     I mean you cannot use "GPAddIn.GPAPP.StopProcessing()" in GPCallBackClass scope.

    It cause circular dependency. You could not even compile or build.

    • Post Points: 0
  • 05-18-2009 1:07 AM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

    thank you for your reply

    but what aboutthis error:

    Error 1 Cannot register assembly "D:\Edita\NetProjects\DynamicsGPAddin1\HowToTestContinuumAPI\bin\Debug\HowToTestContinuumAPI.dll". The specified module could not be found. (Exception from HRESULT: 0x8007007E) HowToTestContinuumAPI
    "

     please advise this error appear only when when i select "Register for COM interop  (in Project -> Properties -> Build )"

    so please advise me.

    • Post Points: 0
  • 05-18-2009 12:20 PM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

    Let's try Uncheck the Com Interop

    And comment this line of code: HowToTestContinuumAPI.GPAddIn.GPAPP.StopProcessing();

    And then complie. Let me know if you still have error.

    • Post Points: 0
  • 05-19-2009 1:49 AM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

    Dear

    the only problem i am facing now is if i "Uncheck the Com Interop" then i have no errors in buiding. but when running GP i have this error: "Specified cast is not valid"

    and when i "check the Com Interop" then i have this error when building:

    "Error 1 Cannot register assembly "D:\Edita\NetProjects\DynamicsGPAddin1\HowToTestContinuumAPI\bin\Debug\HowToTestContinuumAPI.dll". The specified module could not be found. (Exception from HRESULT: 0x8007007E) HowToTestContinuumAPI
    "

    so please advise me

    tell me what i did wrong.

    i need your help.

     

    • Post Points: 0
  • 05-19-2009 2:04 AM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

     After you uncheck the Com Interop

    And comment this line of code: HowToTestContinuumAPI.GPAddIn.GPAPP.StopProcessing();

     Did you get Error in compile time?

    • Post Points: 0
  • 05-19-2009 5:50 AM In reply to

    Re: Why error when trying to "RegisterFocusTrigger()"?

    NO

    but when i uncheck the Com Interop then i have a problem while buiding my application

    • Post Points: 0
Page 1 of 2 (21 items) 1 2 Next >