none
problem to get an array of structure in the vb.net from a c++ dll RRS feed

  • Question

  • Hello folks,

    I have a problem to get an array of structure in the vb.net from a c++ dll.

    In the dll c++, the structure is like :

    typedef struct NOR_Results
    {
    	int pInit;
    	SAFEARRAY *TestResults;
    	double Mean;
    	double StDev;
    } NOR_Results;

    Where TestResults is a pointer on a structure.

    The c++ dll call function is :

    DIST_API int __stdcall  Cpp_NOR_Compute_Tests(NOR_Results *oResults);

    In the vb.net side the structure is defined like this:

    <StructLayout(LayoutKind.Sequential, Pack:=8)>
    Structure nor_results
            Public pinit As Integer
            <MarshalAs(UnmanagedType.SafeArray)> Public testresults() As NOR_TestResults
            Public mean As Double
            Public stDev As Double
    End Structure

    I defined the dll function call like this :

     Private Declare Function Cpp_NOR Lib "XLSTATLINK.dll" ( <MarshalAs(UnmanagedType.Struct)> ByRef oResults As nor_results) As DoubleI

    The problem is when i call the function Cpp_NOR, the structure array nor_results.testresults is always empty !!!!

    Please help me

    Tuesday, January 5, 2016 10:44 AM

Answers

  • Hello all,

    Thanks for your interest about my problem.

    I resolve it by using correctly interop COM and a .idl file in c++ side where I defined my structure.

    • Marked as answer by Sami_Addinsoft Thursday, January 14, 2016 2:21 PM
    Thursday, January 14, 2016 2:21 PM

All replies