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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:27:45+00:00 2026-05-25T03:27:45+00:00

I have an unmanaged dll that contains a function to read a data from

  • 0

I have an unmanaged dll that contains a function to read a data from a file. I wrote a CLI wrapper for it.

To test whether it is working, I wrote a simple CLI program calling the wrapper class and the data read method. It worked fine.

I used that dll in a c# program but the data is not read properly. It reads but the data read is not proper.

CLI function:

void FileReader::ReadFile()
{
int ret;
STRUCT head;        
STRUCT1 *sqar;      

memset ( ( void * )&head, 0, sizeof ( STRUCT) );
sqar = ( STRUCT1 * )NULL;

ret = Read_func( "somefile.someformat", &head, &sqar );
}

CLI EXE:

int main(array<System::String ^> ^args)
{
FileReader reader;
reader.ReadFile();
Console::WriteLine(L"Hello World");
return 0;
}

This works fine. When I debug, the code flows through and reads the data properly.

C# code:

{
        FileReader filereader= new FileReader ();
        filereader.ReadFile();

}

When I import the CLI dll in the C# project and access the code as above the data in not read properly.

STRUCT has int as members and it is read properly.STRUCT1 has int, double and structure pointers as members which is not read properly. What could be possibly wrong?

  • 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-25T03:27:46+00:00Added an answer on May 25, 2026 at 3:27 am

    The solution was to change the Struct Member Alignment property under C/C++ > Code Generation from 1byte 1 byte /Zp1 to Default. Simple.

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

Sidebar

Related Questions

I have a very simple DLL written in unmanaged C++ that I access from
I have a unmanaged DLL that exposes a function that takes a pointer to
I have an unmanaged DLL with a function that can run for a long
we have a C++ Win32 DLL that reads data from Excel. The application uses
I have a Visual Studio 2010 solution that contains C# (managed), C++/CLI (unmanaged) and
I have been provided with an unmanaged C++ DLL that contains several classes. I
I have an unmanaged DLL that gets called from .NET with pre-allocated buffers to
I've an unmanaged dll that exports the folowing function: SomeData* test(); Let's assume SomeData
I have a C# dll that I need to call from unmanaged C++. The
I have an unmanaged class that I'm trying to dllexport from a managed DLL

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.