none
C# error when using VB Activex dll functions.

    Question

  • Hello can sombody help in solving a problem

     I am having a problem when trying to call the function of VB ActiveX dll from C# and I am getting the error show at the end.

    The VB Function is

    Public Function GetStatistics(ByRef varStats() As Variant, Optional ByVal stStatType As e_STAT_TYPE = e_stCLIENT_STATS)  As Long

    And the RCW has created the function as follows (when adding ref from Visual studio)

    int GetStatistics(ref Array varStats, e_STAT_TYPE stStatType);

    The problem is we cannot create the object of Array class as its abstract class and so what I am doing is creating an object array object and type casting it to the Array ref as follows.

     

    object[] varstats = new object[0];

    Array obj1 = varstats;

    objAlm.GetStatistics(ref obj1, e_STAT_TYPE.e_stCLIENT_STATS)

    And the RCW has created the function as follows (from TLBIMP.exe)

     

    int GetStatistics(ref object[] varStats, e_STAT_TYPE stStatType);

    object[] varstats = new object[0];

    objAlm.GetStatistics(ref varstats, e_STAT_TYPE.e_stCLIENT_STATS)

    This is giving the following error.

    ---------------------------

    Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE))

    ---------------------------

    OK   

    Have you ever seen this error? Do you have any idea?

    Waiting for your reply…

    Regards,

    Seshu.

    Monday, May 08, 2006 1:21 PM

Answers

  • Solved the problem by changing the following

    object[,] varstats = new object[0,0];

    Array obj1 = varstats;

    Wednesday, May 10, 2006 10:36 AM