Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Getting a variant containing safe array of Double Values from MFC ActiveX in C#?

Getting a variant containing safe array of Double Values from MFC ActiveX in C#?

Scheduled Pinned Locked Moved C#
helpcsharpc++comdata-structures
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    ss431
    wrote on last edited by
    #1

    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

    N 1 Reply Last reply
    0
    • S ss431

      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

      N Offline
      N Offline
      Nissim Salomon
      wrote on last edited by
      #2

      Hi Can you supply the IDL of the Interface that contain the method you are trying to invoke ???

      S 1 Reply Last reply
      0
      • N Nissim Salomon

        Hi Can you supply the IDL of the Interface that contain the method you are trying to invoke ???

        S Offline
        S Offline
        ss431
        wrote on last edited by
        #3

        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

        N 1 Reply Last reply
        0
        • S ss431

          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

          N Offline
          N Offline
          Nissim Salomon
          wrote on last edited by
          #4

          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];

          V 1 Reply Last reply
          0
          • N Nissim Salomon

            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];

            V Offline
            V Offline
            venkyhyd
            wrote on last edited by
            #5

            any suggestions on the similar issue posted http://www.codeproject.com/script/Forums/View.aspx?fid=1649&msg=2752382[^]:confused::confused:

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups