1

I am trying to invoke one function of a C# application from Java application using Jacob COM interface. I got the ActiveXComponent from the registry entry. I have to call one method

BaseElement AddItem(
    string name,
    ElementType type
)

here ElementType is an ENUM in the C# application. But I am not able to get the elsemnt type using invokeGetComponent/getPropertyAsComponent.

Interestingly I am able to call the same method as below,

ActiveXComponent appHandler= new ActiveXComponent("Application_name");
ActiveXComponent projectHandler = appHandler.invokeGetComponent("CreateProject", new Variant("C:\\temp"), new Variant("test"));

projectHandler.invokeGetComponent("AddItem", new Variant("item1"),new Variant(0));

This method is doing its duty using integer instead of ElementType but throwing exception

com.jacob.com.ComFailException: A COM exception has been encountered: At Invoke of: AddItem Description: 80004002 / No such interface supported at com.jacob.com.Dispatch.invokev(Native Method) at com.jacob.com.Dispatch.invokev(Dispatch.java:625) at com.jacob.com.Dispatch.callN(Dispatch.java:453) at com.jacob.activeX.ActiveXComponent.invoke(ActiveXComponent.java:476) at com.jacob.activeX.ActiveXComponent.invokeGetComponent(ActiveXComponent.java:391)

Is there any ways to get the ENUM type ElementType given in the application ? Seems like the ElementType is in another namespace in C#.

Rakesh KR
  • 6,357
  • 5
  • 40
  • 55
Livin
  • 41
  • 1
  • 8
  • The ENUM ElementType have numbers as below, value1 (0), value2(1), value3(2) and somehow this conversion is happening in C# application. But the exception is always thrown – Livin Dec 14 '15 at 08:38
  • able use this function successfully from C# code. application = Activator.CreateInstance(Type.GetTypeFromProgID("Application_name")); Type elementtype1 = application.GetType().Assembly.GetType("ElementType"); object obj1= Enum.Parse(elementtype1, "value1"); ......... object item1 = CallCOMMethod(project1, "AddItem", new object[] { "Item1", obj1}); – Livin Dec 14 '15 at 09:26

0 Answers0