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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:48:22+00:00 2026-06-01T02:48:22+00:00

This is the situation. I am writing a backend application in C++ and my

  • 0

This is the situation. I am writing a backend application in C++ and my colleagues are using C# for the frontend. Basically, my backend application does image processing on images received from the C# frontend and returns a text file with data about the image.
What we were doing earlier was writing the images to disk and calling the C++ application with the file path of the image as a parameter. However, this writing/reading from disk has become a bottleneck, so we are wanting to convert the C++ application to a DLL.

At the basic level, what I want is to expose a single method from my C++ application to the C# one through a DLL (the C# application is web-based):

int ProcessImage(System::Bitmap^ image, System::String ^results)

How can I go about doing this? I am using VC++ Express 2008 and my C++ code currently compiles with CLR (although I have mixed a lot of native C++ code inside).

I have been looking around on the web, but am still stuck on how to do this. I think a C++/CLI DLL is the best option, but how do I do this?
Writing a DLL in C/C++ for .Net interoperability

  • 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-01T02:48:23+00:00Added an answer on June 1, 2026 at 2:48 am

    I finally figured it out. What you need to do is:

    1. In your C++ project, set the option in Visual C++ to compile with clr pure, which makes the project a C++/CLI one
    2. In your C++ project, expose methods by creating a public ref class:

      public ref class Interop
      {
      public:
          //! Returns the version of this DLL
          static System::String^ GetVersion() {
              return "3.0.0.0";
          }
      
          //! Processes an image (passed by reference)
          System::Int32^ Process(Bitmap^ image);
      }
      
    3. In a C# program, add a reference to the C++ DLL you compiled
    4. In the C# program, call these methods (i.e. Interop::Process(myBitmapInCS))

    I believe this method is called “implicit P/Invoke”
    Hope this helps!

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

Sidebar

Related Questions

This situation arises from someone wanting to create their own pages in their web
In this situation I am trying to perform a data import from an XML
I'm writing a java application. Currently this produces a file called trace.txt in the
I am writing an app for the iPhone and arrived at this situation. I
This if else statement does not work: (in this situation it displays 'x is
I've had this situation occur a number of times in the library I'm writing,
I am writing to the text file some data. I am using this code:
When I'm writing code with QtCreator (2.4.1), I'm very often in this situation: something
In this situation I have two models, Comment and Score. The relationship is defined
I ran across this situation this afternoon, so I thought I'd ask what you

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.