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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:01:36+00:00 2026-05-13T15:01:36+00:00

I have a class implemented in C++ that’s responsible for the arithmetic computation of

  • 0

I have a class implemented in C++ that’s responsible for the arithmetic computation of the program, and an interface using WPF. I process the input with C# but then how can I use my C++ class?

I’ve seen some comments about making a managed C++ wrapper class to interact with it, but I don’t know where to start. Nor do I know how I’d go to compile it along with all the other code. I can’t really find a tutorial on this, and the stuff google shows on managed C++ doesn’t really seem helpful.

Anything out there to help me out? This doesn’t seem unreasonable to me.

EDIT Tried m3rLinEz solution but it’s giving me a BadImageFormatException, I think it’s because the DLL isn’t generated. I did everything as told, I don’t know what happened. Any ideas?

  • 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-13T15:01:36+00:00Added an answer on May 13, 2026 at 3:01 pm

    Have you take a look at C++/CLI?

    Let me give a very short example. Here is the source file from a Visual C++ -> CLR -> Class Library project. It basically get Windows username and return it.

    Please note that, in order to get this compiled, you have to go into project settings and mark "Additional Dependencies" as "Inherit from parent" because we are using those Windows libs (kernel32.lib, user32.lib, ..)

    // CSCPP.h
    
    #pragma once
    
    #include "windows.h"
    
    using namespace System;
    
    namespace CSCPP {
    
        public ref class Class1
        {
            // TODO: Add your methods for this class here.
        public:
            String^ GetText(){
                WCHAR acUserName[100];
                DWORD nUserName = sizeof(acUserName);
                if (GetUserName(acUserName, &nUserName)) {
                    String^ name = gcnew String(acUserName);
                    return String::Format("Hello {0} !", name);
                }else{
                    return gcnew String("Error!");
                }
            }
        };
    }
    

    Now created a new C# project and add reference to our first C++/CLI Class Library project. And then call the instance method.

    namespace CSTester
    {
        class Program
        {
            static void Main(string[] args)
            {
                CSCPP.Class1 instance = new CSCPP.Class1();
                Console.WriteLine(instance.GetText());
            }
        }
    }
    

    This gave the following result on my machine:

    Hello m3rlinez !

    C++/CLI is basically a managed extension over C++ standard. It allows you to utilize CLR classes and data types in your C++/CLI project and also expose this to managed language. You can created a managed wrapper for your old C++ library using this. There are some weird syntaxes such as String^ to define reference type to CLR String. I find "Quick C++/CLI – Learn C++/CLI in less than 10 minutes" to be useful here.

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

Sidebar

Ask A Question

Stats

  • Questions 314k
  • Answers 314k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer OnItemDataBound may be too late to add controls. Try it… May 13, 2026 at 11:06 pm
  • Editorial Team
    Editorial Team added an answer For anyone that comes across this: I had to use… May 13, 2026 at 11:06 pm
  • Editorial Team
    Editorial Team added an answer LINQ to entities is completely isolated from your data access… May 13, 2026 at 11:06 pm

Related Questions

I have a class, A , in C++/CLI which derives from a templated base
I am working with an open-source UNIX tool that is implemented in C++, and
I have implemented a class in C++. I want to use it with Python.
I have a program that is been implemented in C++ which I now want
I understand that a class that consists of nothing but public static member functions

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.