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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:19:18+00:00 2026-05-23T16:19:18+00:00

I have a dll project with C++ like: _declspec(dllexport) bool __stdcall cppPage1(char* Input, char*

  • 0

I have a dll project with C++ like:

_declspec(dllexport) bool __stdcall cppPage1(char* Input, char* Output)
{
    string str1 = Input;
    //blablabla
    strcat(Output, "Result#as#a#string");
}

And in C#, I use this with:

[DllImport("ReportContent.dll")]
extern static bool cppPage1()
public void Page1()
{
    StringBuilder s1 = new StringBuilder("1#3", 10000);
    StringBuilder s2 = new StringBuilder("", 10000);
    cppPage1(s1, s2);
}

As shown above, I “get” some RAM with StringBuilder where C# and C++ both can read/write. C++ read Input from RAM and did calculating logics and write to Output which is also in RAM so that C# can get the result.
Let StringBuilder.Length = 10000 to make sure that enough in most situations.

I don’t think it is a good practice to consider RAM in C#.
What is the right way of communicating between C# and C++?

  • 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-23T16:19:19+00:00Added an answer on May 23, 2026 at 4:19 pm

    You should translate the signature from C to C# using P/Invoke marshaling rules. There are a number of tools to help you with that.

    Here is the documentation

    • MSDN
    • http://pinvoke.net/
    • http://www.red-gate.com/pinvoke/download P/Invoke addin
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a header file in a managed DLL project like so: Enums.h: #pragma
I have a project like this: Test Solution Project TestApplication References: TestFunctions.dll(ver 1.0.0.0),Project TestDLL
VS2005.NET I have a website project that references 3rd party dll's and i'd like
My project structure is like CodeCampServer structure, etc. UI.dll, Core.dll and DependencyResolution.dll that have
I have a DLL project in VS 2008 Pro which uses OpenMP. I use
I have an C# dll project for which I have to store the runtime
I have a a Win32 DLL project in VS2008, it is written in a
I have two projects, the DLL project which has all my logic and data
Guys; How are you doing today? I have to create a dll project on
I have a .DLL that i include in my Visual Studio 2008 project. The

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.