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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:14:22+00:00 2026-05-26T14:14:22+00:00

My question is what’s the best way to create an inteface with C++ code.

  • 0

My question is what’s the best way to create an inteface with C++ code.

Basically so far I have a console project in c++, that works as I expect to, but I now want to make a GUI for it. The choices to me seemed to be:

  1. Make a dll of the c++ project, and then make a C# form which uses the dll to do the logic.

  2. Same as 1 except with VB.

  3. Use QT or something eqvilent and make the inteface in the same project.

I’ve been trying option 1 for quite sometime. I made the library I believe successfully by making a library project in Visual Studio 2005. I then put it in my c# project but I then had a problem of being able to instantuate my class, but the c# project couldn’t see my methods.

The only fix I could find to this was to use the ref keyword. The problem with this was then not being able to mix managed and unmanaged code and trying this on one of the larger classes produced about 250 errors.

Option 2 i had the same problem with.

I’ll start option 3 if I have to, I just wondered if I was missing anything fundamental or any suggestions in general?

Cheers for reading.

  • 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-26T14:14:23+00:00Added an answer on May 26, 2026 at 2:14 pm

    You absolutely can use C++ code from C#, but if it’s unmanaged C++ code, you have to delve into the realm of pinvoke to call your code.

    If you’re attempting to leverage an existing C++ library from .NET, one of the easiest ways to do this is by using C++/CLI as a wrapper around your unmanaged library. C++/CLI compiles into .NET bytecode, but features lots of automatic unmanaged interop. A phrase that’s often floated about when using C++/CLI unmanaged interop is “it just works”. It’s an accurate phrase.

    Once you have a C++/CLI wrapper for your unmanaged code, C# should be able to see everything exposed by your C++/CLI library.

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

Sidebar

Related Questions

Question for the video tag, the following code works for every browsers expect opera
Question is about what is the best way to create vector of vector s.
Question - I've noticed that some applications I test with have calls to another
Question Is it possible to create a second Preference Dialog that can take some
Question I have two compilers on my hardware C++ and C89 I'm thinking about
Question slightly in the abstract... We have a situation where we have a struct
Question 1) I have a control to which I add an attribute from the
Question 1: Is is possible to throw an exception that will not be caught
Question: I'm interested to know the best practice for killing a long standing operation
Question Is there a way to define a method only once in C# (in

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.