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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:59:41+00:00 2026-06-11T19:59:41+00:00

I have a C DLL being called by a C# app, exchanging data using

  • 0

I have a C DLL being called by a C# app, exchanging data using pinvoke. In the following,
I have a simple class consisting of an int and 2 arrays of chars.
Everything works dandy up to a point: the C# calls the DLL correctly (using “getStreamGroup”), and the DLL fills the passed streamGroup structure with the correct data.

But, once the C function is done, and we are back on the C# side, the streamGroup that got passed and filled with the correct data is now barren: 3 null values. No errors/warnings from VS2010. This is a 64bit app.
Any ideas?

#define STREAM_COUNT 9000

typedef struct s_streamGroup
{
    int systemDefinedGroup;

    char name[BUFFER_SIZE_128];
    char streamList[STREAM_COUNT];

} streamGroup;


public class streamGroup
{
    public int systemDefinedGroup;

    [MarshalAs(UnmanagedType.ByValArray, SizeConst = constants.BUFFER_SIZE_128)]
    public byte[] name;

    [MarshalAs(UnmanagedType.ByValArray, SizeConst = constants.STREAM_COUNT)]
    public byte[] streamList;
}


DLL int getStreamGroup( int groupIndex, streamGroup *RequestedStreamGroup)
{   
    *RequestedStreamGroup = Environment.StreamGroup[groupIndex];
    return(DLL_NO_ERROR);
}

[DllImport(constants.DLL_PATH, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern int getStreamGroup([In] int groupIndex, [In, Out] streamGroup group);
  • 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-11T19:59:42+00:00Added an answer on June 11, 2026 at 7:59 pm

    You need [StructLayout(LayoutKind.Sequential)] before streamGroup.

    If that’s not enough please make your code a little more clear. I’m not sure what code is in what project (if I understand correct you have a native C++ project and a C# project). Please give two separate listings showing which is which, or explain what you’re doing if my understanding is incorrect.

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

Sidebar

Related Questions

I have a WPF DLL being called from an unmanaged DLL. The WPF DLL
I've got an unmanaged C++ dll which is being called from a C# app,
I have a dll in C# which returns a class object. DLL code: Person.cs:
I have a DLL which outpus data to a stream. But it adds a
I have a .dll library which exports a function in the following format: _Java_folder1_folder2_folder3_JavaClassName_javamethodname@16
I have a DLL that was written in C++ and called from a C#
If I create a dll called xaisoft.dll like this: Using System; Using System.Reflection; [assembly:AssemblyVersion(1.0.0.0)]
The scenario is the following: Lets say I have this application App that depends
I have been looking into the Microsoft.Web.Administration.dll and the ServerManager class, trying to control
I have been using SDL with success to learn OpenGL, however I am following

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.