Hello,
I am implementing the 'Dex2Example' example and the code throws an exception while trying to retrieve the data. While I can retrieve data using the form, as soon as trigger the CreateRData as a console application it throws the said exception:
An exception of type 'System.InvalidCastException' occurred in e_webservice.exe but was not handled in user code. It's not possible to associate an object COM of type 'System.__ComObject' to the interface 'Dex2.IDex2Mgr3'. This operation has failed because the call QueryInterface in the COM component (...) RESULT: 0x80004002 (E_NOINTERFACE)
The excpetion is thrown on the line
MyRData = MyDex2Mgr.CreateRData(MyDex2Cookie);
mydex2cookie value is 1 and the connection status is 'suceeded'.
The MyDex2Mgr initialization is as follows:
public void CreateDex2Mgr() { // Create the Dex2 manager MyDex2Mgr = MyEikonDesktopDataAPI.CreateDex2Mgr(); // Initialize the Dex2 manager and retrieve a session cookie if (MyDex2Mgr != null) MyDex2Cookie = (MyDex2Mgr as IDex2Mgr2).Initialize(DEX2_MetadataCaller.DE_MC_ADC_UNKNOWN); }
Cheers,
Duarte
Hi @duarte_quintelauarte, there are a few things that you should do to make sure that your code will work just fine in the console application:
#region Dispatcher public static DispatcherFrame Frame; //the object is required in order to release the Windows message pump while executing asynchronous calls. public static void PushDispatcherFrame() { Dispatcher.PushFrame(GetDispatcherFrame()); } public static void StopMessagePump() { Frame.Continue = false; Frame = null; } public static DispatcherFrame GetDispatcherFrame() { return Frame ?? (Frame = new DispatcherFrame()); } #endregion
Let me know if it works.
Hello @Zhenya_Kovalyov
I've implemented the Dispatcher Frames method and the [STAThread] attribute on the main function.
Now, I've got another error on
MyDex2Cookie = (MyDex2Mgr as IDex2Mgr2).Initialize(DEX2_MetadataCaller.DE_MC_ADC_UNKNOWN);
The exception is as follows:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' in eikon.exe Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG
I have the following dll's referenced in my project:
- Interop.Dex2
- Interop.EikonDesktopDataAPI
Thank you for your time,
Duarte
It still looks as if you are activating and using the object in different threads. Could you drop me an email at evgenij.kovalev@tr.com and we can have a look at your code together.