Menu

Instance creation failing

abcl
2008-07-02
2012-11-29
  • abcl

    abcl - 2008-07-02

    Hi,
    I am new to j-interop as well as com/dcom , i am facing a problem on createCOMInstance method .
    I am able to communicate with a dll then i am calling a method on it(GetService).
    The code is given below

    JIVariant phoneVariant[]=dispatch.callMethodA("GetService",new Object[] {umEmPhoneDevice,voiceServerName,JIVariant.EMPTY});

    System.out.println("com ooo===="+phoneVariant[0]);
              
    JIComObjectImpl un=(JIComObjectImpl)phoneVariant[0].getObjectAsComObject(unknown);
            IJIComObject com=un.getCOMObject();  

       IJIDispatch disp=(IJIDispatch)JIComFactory.createCOMInstance(JIComFactory.IID_IDispatch,com));

    but it is throwing an exception "The requested object does not exist.  [0x80010114]" when createCOMInstance method is called.

    Thanks and Regards,
    Rahul

     
    • Vikram Roopchand

      Hi,
         Do you want a reference to IDispatch on "com" or is "com" an IDispatch interface itself ?

      best regards,
      Vikram

       
      • abcl

        abcl - 2008-07-03

        Hi ,
        The object which i got from variant is a org.jinterop.dcom.core.JIComObjectImpl object and
        I expect IDispatch from it, when i do .isDispatchSupported() it is returning me false.

        I used 2.0 version but when i am ivoking the method on dll it is throwing an exception "An internal error occurred. " and the same thing works in older version of j-interop.

        Let me explain the whole problem to you.
        We have 2 dlls
        1. service locator dll
        2. PhoneDevice dll

        purpose of service locator is to locate the service(Phone Device Service). Both the dll's are on server .I  am able to connect to the service locator and can call GetService method. Signature of GetService is given below.

        IUnknown* GetService(
                        [in] BSTR progid,
                        [in, optional] VARIANT location,
                        [in, optional] VARIANT constraints);

        And below is the code that i have written

        //-------------------------code--------------------------------
        JIString umEmPhoneDevice = new JIString("UmEmPhoneDevice");

        JIVariant phoneVI[]=dispatch.callMethodA("GetService",new Object[] {umEmPhoneDevice.VariantByRef});
        IJIComObject co=(IJIComObject)phoneVI[0].getObjectAsComObject(unknown);
        System.out.println(co.isDispatchSupported());
        //returning flase

        co.queryInterface("ABEDBBCA-F399-11D3-A161-00C04FA08FB0");
        //-------------------------code--------------------------------

        but when i try to get IDispatch out of co i get error and also if I do co.queryInterface
        where (ABEDBBCA-F399-11D3-A161-00C04FA08FB0) is a uuid of one of the interface in Phonedevice Dll  I get an exception "The requested object does not exist. "

        I want phone device object so that i can call methods of phone device.

        Thanks and regards,
        Rahul.

         
        • abcl

          abcl - 2008-07-10

          Hi vikram ,
          I am stuck at the same point , getting same error , as i mention in my earlier post , i am getting IUnknown (Which does not support IDispatch interface) on which i want to do queryinterface and obtain 2 different IDispatch Object. Is there any way in j-interop through which can get both the objects.

          Thanks and regards,
          Rahul

           
          • Vikram Roopchand

            Hi Rahul,
                     Did you have a look at any of the examples. They may help you get started. Also, I suggest (if you have already not done so) to move to 2.0.

            Thanks,
            best regards,
            Vikram

             
            • abcl

              abcl - 2008-07-10

              Hi Vikram ,
              Thanks for reply  , I moved to 2.0 but the program I have written using version 2.0 works on server(where dll is hosted) not on client pc . Also the same problem persist in version 2.0 which I am facing in previous version.

              Thanks and Regards,
              Rahul

               
              • Vikram Roopchand

                Okay, I looked at your sample IDL. The Method returns an IUnknown*, it does not support IDispatch. You said it worked in an older version of j-Interop. Could you show me that code. May be I can help you using that.

                best regards,
                Vikram

                 
                • abcl

                  abcl - 2008-07-11

                  JISystem.setAutoRegisteration(true);
                  JISystem.setInBuiltLogHandler(false);
                  session = JISession.createSession(domain, userId, password);
                  comServer = new JIComServer(JIProgId.valueOf sessssion,"UnifiedMessenger.UmServiceLocator.1"), host, session);

                  //Com Objects
                  unknown = comServer.createInstance();
                  System.out.println("Is dispatch supported======"+unknown.isDispatchSupported());
                  System.out.println("Interface identifier======"+unknown.getInterfaceIdentifier());
                         
                  dispatch= (IJIDispatch) JIComFactory.createCOMInstance(JIComFactory.IID_IDispatch, unknown);
                     
                  JIString umEmPhoneDevice = new JIString("UmEmPhoneDevice");
                  JIVariant voiceServerName=new JIVariant("10.52.32.241");     
                             
                  JIVariant vi[]=dispatch.callMethodA("getservice",new Object[] {umEmPhoneDevice.VariantByRef,voiceServerName,JIVariant.OPTIONAL_PARAM});

                   
    • abcl

      abcl - 2008-07-02

      I want reference to IDispatch so that i can call methods.

      Thanks and regards
      Rahul

       
      • Vikram Roopchand

        No, my question was is the object which you got from Variant , actually an instance of IDispatch or do you expect to obtain IDispatch from it. For the latter the IDispatch interface may not be supported (that is why the exception). For the former you can use the other createComInstance method and typecast to IJIDispatch. Btw if you are just starting , I suggest moving to 2.0 . The interfaces you are using currently are no longer present in 2.0

        Thanks,
        best regards,
        Vikram

         

Log in to post a comment.