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

  • SEARCH
  • Home
  • 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 6988301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:03:42+00:00 2026-05-27T19:03:42+00:00

I have a C# dll exposed to vb6 via com-interop. This is all working,

  • 0

I have a C# dll exposed to vb6 via com-interop. This is all working, but I am noticing something strange when I pass an array of a custom objects from .Net into VB6.

Accessing the array from VB6 is what baffles me. If I access the array directly I have to do it like this:

Dim manager as New ObjectManager

'Access with two sets of parentheses:
msgbox manager.ReturnArrayOfObjects()(0).Name

However, if I copy the array first I can access it how I would normally expect to:

Dim manager as New ObjectManager
Dim objectArray() As CustomObject

'copy the array
objectArray = manager.ReturnArrayOfObjects

'access normally:
msgbox objectArray(0).Name  

In the first case I had to use two sets of parentheses: manager.ReturnArrayOfObjects()(0).Name In the second case I could just use one set of parentheses: objectArray(0).Name

Does anyone know why this is the case? Am I doing something wrong here with the interop maybe?

Here is a quick stub/sample of the C# interop code.

[ComVisible(true)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("[Guid here...]")]
public interface IObjectManager
{
    [DispId(1)]
    CustomObject[] ReturnArrayOfObjects();
}

[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[Guid("[guid here...]")]
public class ObjectManager: IObjectManager
{
    public CustomObject[] ReturnArrayOfObjects()
    {
        return new CustomObject[] { new CustomObject(), new CustomObject() };
    }
}

The class CustomObject() is also exposed to com-interop and working just fine. Please let me know if you need me to post anymore code, but I think these little snippets represent the problem well enough to begin with.

Thanks in advance for your help.

  • 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-05-27T19:03:43+00:00Added an answer on May 27, 2026 at 7:03 pm

    ReturnArrayOfObjects() in the C# code is a method. Your VB6 code is invoking the method, which returns the array, and then accessing the first element. The difference between this

    msgbox manager.ReturnArrayOfObjects()(0).Name 
    

    and this

    objectArray = manager.ReturnArrayOfObjects    
    msgbox objectArray(0).Name 
    

    Is that in the second, you invoke the method by itself without accessing the first element, and VB is allowing you to leave off the parentheses from the method call. Conversely, the language is not allowing you to leave off the parentheses when you directly access the first element. It’s simply a language feature, it’s not a “double parentheses array syntax” issue.

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

Sidebar

Related Questions

I have a DLL with some COM objects . Sometimes, this objects crashes and
I have a .NET dll which has some interfaces\classes which are exposed to com.
I have rephrased this question. When .net objects are exposed to COM Clients through
I have DLL and application that will call some function in this dll. For
I have a dll that was written in c++, I need to use this
I have a .NET v2.0 Dll that exposes a few classes to COM. The
I have some MSVC++ compiled DLL's for which I have created COM-like (lite) interfaces
I have a C# .NET class library which I have exposed in COM by
I have an EXE (app.exe) that calls a COM exposed method in a C#
I have a third-party (Win32) DLL, written in C, that exposes the following interface:

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.