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 7840513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:48:38+00:00 2026-06-02T15:48:38+00:00

Let me begin by stating, I’m not a COM developer. I know standard C++,

  • 0

Let me begin by stating, I’m not a COM developer. I know standard C++, C#, and Java.

I have a C# library that will be called from Managed C++. I’ve added C++ classes using Visual Studio 2010 –> MFC Class from TypeLib. The autogenerated C++ class doesn’t compile though. It is obviously missing a return statement. How do I fix this? I seriously appreciate any help.

C# Class from Library

[Serializable]
[
       ClassInterface(ClassInterfaceType.AutoDual),
       ProgId("Response")
]
public class Response
{
    public static readonly int NUM_DATA = 6;

    public Response()
    {
        data = new Data[NUM_DATA];
        for (int i = 0; i < NUM_DATA; ++i)
        {
            data[i] = new Data();
        }
    }

    private Data[] data;
    public Data[] Data
    {
        [return: MarshalAs(UnmanagedType.SafeArray)]
        get
        {
            return data;
        }
    }
}

Managed C++ Generated Class

class CResponse : public COleDispatchDriver
{
public:
    CResponse(){} // Calls COleDispatchDriver default constructor
    CResponse(LPDISPATCH pDispatch) : COleDispatchDriver(pDispatch) {}
    CResponse(const CResponse& dispatchSrc) : COleDispatchDriver(dispatchSrc) {}

    // _Response methods
public:
    SAFEARRAY * get_Data()
    {
        InvokeHelper(0x60020004, DISPATCH_PROPERTYGET, VT_EMPTY, NULL, NULL);
    }
}
  • 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-02T15:48:41+00:00Added an answer on June 2, 2026 at 3:48 pm

    It seems there are threecommon solutions to this problem. The first is to put the return array as a parameter to the function. So like this:

    CustomData[] getCustomDataArray();
    void getCustomDataArray(out CustomData[]);
    

    The second option is to write a function for accessing the array rather than using the whole thing.

    CustomData getCustomDataAt(int index);
    void setCustomDataAt(int index, CustomData data);
    

    The final option is to change the MarshalAs attribute. I will be using the first option as it seems to be the most commonly accepted solution. Hope this helps others.

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

Sidebar

Related Questions

let me begin by stating that's i'm dreadful at math. i'm attempting to reposition
Let me begin by stating that this is a question of aesthetics. I've solved
First, let me begin by saying that I have done a lot of research
Let me begin by saying this; I know that similar questions exist, but they
Let me begin by saying that, yes, I know that the stock Android lock
Before I begin, let me just say that I know my question is almost
To begin with, let me say that I understand how and why the problem
Let's say I have a structure named vertex with a method that adds two
Let me state up front that I have an infantile understanding of Monads. I
Let me begin by saying my Oracle knowledge is minimal. We have a proprietary

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.