Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8623699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:20:49+00:00 2026-06-12T07:20:49+00:00

I have a COM class (developed in C++, just in case it matters), which

  • 0

I have a COM class (developed in C++, just in case it matters), which has a method “GetStructList” which should return a list of some custom type, and I’m developing a .NET application which should get that list.

I control the COM class code as well as the application, and I am unable to obtain the data.

The COM class code:

1- IDL:

HRESULT GetList([in,out] SAFEARRAY(struct MyStruct)* myStructs);
// I have also tried with [out] instead of [in, out]

[uuid(628913FC-CC26-1654-472F-0B70CC39DEE0)]
struct MyStruct
{
    int myInt;
    DOUBLE myDouble;

};

2- CPP:

STDMETHODIMP MyClass::GetList(SAFEARRAY** myStructs)
{
    SAFEARRAY* psa = *myStructs;
    SAFEARRAYBOUND sab = {someSize, 0};
    MyStruct *pData;
    IRecordInfo *pRI;
    HRESULT hr;

    hr = GetRecordInfoFromGuids(LIBID_MyCOMLib, 1, 0, 0x409, __uuidof(MyStruct), &pRI);
    psa = SafeArrayCreateEx(VT_RECORD, 1, &sab, pRI);
    pRI->Release();
    pRI = NULL;
    hr = SafeArrayAccessData(psa, (void**)&pData);
    for (size_t i = 0; i < someSize; i++) 
    {
        pData[i].myInt = someInt;
        pData[i].myDouble = somedouble;
    }
    hr = SafeArrayUnaccessData(psa);

    return S_OK;
}

.Net Code (VB):

Option Strict
...
<MarshalAs(UnmanagedType.SafeArray, safearraysubtype:=VarEnum.VT_RECORD)>
Private m_List As MyStruct()

Private Sub btnGetList_Click(sender As System.Object, e As System.EventArgs) 
    Dim m_List() As MyStruct
    m_ComObject.GetList(m_List) 

    ' I have tried several other things, getting different errors with each of them'
    'm_ComObject.GetList(CType(m_List, Array))'

    'Dim structs() As MyStruct'
    'Dim arr as System.Array = structs '
    'm_ComObject.GetList(arr)'

    For Each o In cortes
        Dim s As MyStruct = CType(o, MyStruct)
        MsgBox(s.myInt)
        Exit For
    Next
End Sub

How can I achieve this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:20:51+00:00Added an answer on June 12, 2026 at 7:20 am

    What is the generated interop signature?

    What exact errors do you get?

    The myStruct argument in COM interface should be [out], not [in, out]

    Is the part:

    Dim m_List() As SceneCutInfo
    m_ComObject.GetList(m_List) 
    

    meant to be:

    Dim m_List() As MyStruct
    m_ComObject.GetList(m_List) 
    

    However, unless you have a really good reason to use SAFEARRAYs (e.g. an Automation compliant interface), I would suggest using normal arrays, as there is no need to fight with VT_RECORD stuff.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed some reusable android component which is basically a class . This
Say i have com.mydomain.myappname. Is it a good idea to put my baseActivity class
I have defined the following class using COM to use the IGroupPolicyObject using C#.NET:
I have the following interface defined to expose a .NET class to COM: [InterfaceType(ComInterfaceType.InterfaceIsDual)]
In my GWT app I have the following model class: import com.google.gwt.user.client.rpc.IsSerializable; public class
I have a class named as order in package com.abc I have another class
I have an ActionMailer class class UserMailer < ActionMailer::Base default from: no-reply@spicy-millennium.com def submission_reminder
com/jniwrapper/win32/ie/WebBrowser class not found. From where can I download jniWrapper library. I have downloaded
I have a config file like package com.mypackage.referencedata.config; @Configuration @ComponentScan (com.mypackage.referencedata.*) public class ReferenceDataConfig
I have a problem with portlet. When i write in portlet.xml standart line <portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</portlet-class>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.