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 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 collection of unmanaged dlls with a C# wrapper around them that
I have a closed source unmanaged DLL coded in C++ that I wanted to
Currently, we use an unmanaged DLL from a vendor that allows us to access
Context: I have a WPF App that uses certain unmanaged DLLs in the D:\WordAutomation\MyApp_Source\Executables\MyApp
When working in the unmanaged world, we have to make sure that we clean
I have a C# class library that contains methods that need to be used
I have a DLL made in C#, this DLL contains some clases like Creator.
We have a managed app, that uses an assembly. That assembly uses some unmanaged
I'm creating a .NET DLL that acts as a wrapper using PInvoke on an
I have a native/unmanaged C++ library with a number of classes that I would

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.