Getting a variant containing safe array of Double Values from MFC ActiveX in C#?
-
Hi All, I have a MFC ActiveX control which has a method which returns a variant which contains a safe array of double values . void Calculate(double value,VARIANT *Result); "Result" variable is of "Out" type. When i'm trying to access this function from C# i'm by passing variable of type "Object" i'm getting RunTime Exception as follows "An unhandled exception of ype 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll Additional information: Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))" Please Anyone help me to solve this problem I can access this from VB 6 without any issues. Thanks in Advance
-
Hi All, I have a MFC ActiveX control which has a method which returns a variant which contains a safe array of double values . void Calculate(double value,VARIANT *Result); "Result" variable is of "Out" type. When i'm trying to access this function from C# i'm by passing variable of type "Object" i'm getting RunTime Exception as follows "An unhandled exception of ype 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll Additional information: Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))" Please Anyone help me to solve this problem I can access this from VB 6 without any issues. Thanks in Advance
Hi Can you supply the IDL of the Interface that contain the method you are trying to invoke ???
-
Hi Can you supply the IDL of the Interface that contain the method you are trying to invoke ???
Hi nissims Thanks for your reply, Below is the IDL for my MFC ActiveX Control library MyActiveXLib { importlib(STDOLE_TLB); // Primary dispatch interface for CMyActiveXCtrl [ uuid(9117C567-1EAD-48B3-BA9E-C4D44852D181), helpstring("Dispatch interface for MyActiveX Control")] dispinterface _DMyActiveX { properties: methods: [id(1), helpstring("method AddDataPoint")] void AddDataPoint(LONG lngIdx, DOUBLE dblXVal, DOUBLE dblYVal); [id(2), helpstring("method AddDataPoints")] void AddDataPoints( LONG lngNoOfPoints, VARIANT varXVals, VARIANT varYVals); [id(3), helpstring("method GetData")] LONG Calculate( DOUBLE dblXVal, VARIANT* varResult); }; // Event dispatch interface for CMyActiveXCtrl [ uuid(07A82910-34BC-43C2-ADAE-A462286D4E10), helpstring("Event interface for MyActiveX Control") ] dispinterface _DMyActiveXEvents { properties: // Event interface has no properties methods: }; // Class information for CMyActiveXCtrl [ uuid(E98E4ED3-C038-4705-8EAB-43AD8A1B75AB), helpstring("MyActiveX Control"), control ] coclass MyActiveX { [default] dispinterface _DMyActiveX; [default, source] dispinterface _DMyActiveXEvents; }; }; "varResult" variable of "Calculate" method will return the SafeArray of Double values. Please suggest me the solution to solve this problem Thanks again
-
Hi nissims Thanks for your reply, Below is the IDL for my MFC ActiveX Control library MyActiveXLib { importlib(STDOLE_TLB); // Primary dispatch interface for CMyActiveXCtrl [ uuid(9117C567-1EAD-48B3-BA9E-C4D44852D181), helpstring("Dispatch interface for MyActiveX Control")] dispinterface _DMyActiveX { properties: methods: [id(1), helpstring("method AddDataPoint")] void AddDataPoint(LONG lngIdx, DOUBLE dblXVal, DOUBLE dblYVal); [id(2), helpstring("method AddDataPoints")] void AddDataPoints( LONG lngNoOfPoints, VARIANT varXVals, VARIANT varYVals); [id(3), helpstring("method GetData")] LONG Calculate( DOUBLE dblXVal, VARIANT* varResult); }; // Event dispatch interface for CMyActiveXCtrl [ uuid(07A82910-34BC-43C2-ADAE-A462286D4E10), helpstring("Event interface for MyActiveX Control") ] dispinterface _DMyActiveXEvents { properties: // Event interface has no properties methods: }; // Class information for CMyActiveXCtrl [ uuid(E98E4ED3-C038-4705-8EAB-43AD8A1B75AB), helpstring("MyActiveX Control"), control ] coclass MyActiveX { [default] dispinterface _DMyActiveX; [default, source] dispinterface _DMyActiveXEvents; }; }; "varResult" variable of "Calculate" method will return the SafeArray of Double values. Please suggest me the solution to solve this problem Thanks again
Hi Sorry about the delay, i just saw your answer now. Are you passing an object argument that encapsulate a double array ???
For example:
object result = new double[10]; -
Hi Sorry about the delay, i just saw your answer now. Are you passing an object argument that encapsulate a double array ???
For example:
object result = new double[10];