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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:15:59+00:00 2026-05-11T07:15:59+00:00

I have an unmanaged C++ DLL which merely exports a single class (not COM…it’s

  • 0

I have an unmanaged C++ DLL which merely exports a single class (not COM…it’s just a simple C++ class) as its interface. I want to use this class in C# but am told that it cannot merely be imported into C#.

What is the right way to use this class in my C# application?

  • 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. 2026-05-11T07:16:00+00:00Added an answer on May 11, 2026 at 7:16 am

    Simple way assuming class Foo:

    1. Create a C++/CLI project, call this FooWrapper.
    2. Make FooWrapper depend on the unmanaged dll (however you normally would).
    3. Create a managed class ManagedFoo which contains a single private instance field of type Foo*.
    4. provide public wrapping functions in ManagedFoo which forward on to the underlying instance field.
    5. Optionally (though recommended):
      • convert parameters from .net idioms (strings and the like) to C++ idioms (std::string or char*)
      • catch unmanaged exceptions and throw managed ones instead

    Then you make your c# code depend on the FooWrapper project/dll and ensure that the unmanaged dll is properly deployed with it, how that is done depends on the unmanaged dll but in the same directory is normally sufficient.

    If the functions do not rely on instances of the class then even simpler is P/Invoke

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

Sidebar

Related Questions

I have a WPF click-once application that makes use of an unmanaged dll. When
I have an unmanged class and a ref class which ar logically connected: public
I have the following unmanaged C++ code: MessageBox( NULL, strMessage, Cool Product, MB_RETRYCANCEL |
What are your thoughts about them? Sometimes I have to write unmanaged code at
I have a collection of unmanaged dlls with a C# wrapper around them that
Basically I have a bunch of unmanaged VC++ static libraries. And the VC++ GUI
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
Have just started using Google Chrome , and noticed in parts of our site,
I have a console application which works perfectly in 32 bit machine. But I'm

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.