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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:35:45+00:00 2026-05-17T02:35:45+00:00

I need an opinion on writing a managed (C#) wrapper for an unmanaged C++

  • 0

I need an opinion on writing a managed (C#) wrapper for an unmanaged C++ DLL.

Let’s say I have an object like this:

public class ManagedObject
{
  public void DoSomethingWithTheObject()
  {

  }
}

and suppose that the DoSomethingWithTheObject() method has to make a call to the unmanaged DLL method.

Now there are two acceptable possibilities that come to my mind:

public void DoSomethingWithTheObject()
{
    DllWrapperClass.DirectCallToUnmanagedMethod(some_value_type);
}

and

public void DoSomethingWithTheObject()
{
    DllWrapperClass.MethodName(this);
}

What I’m basically asking is if

  1. the wrapper class should merely be a wrapper to the unmanaged methods and all objects call those methods directly

  2. the wrapper class should be neatly integrated with the objects and hide as much of the “unmanaged way” of working as possbile

I’m leaning towards the second option, but I’d like to hear some other opinions as both ways have their own pros and cons.

  • 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-17T02:35:46+00:00Added an answer on May 17, 2026 at 2:35 am

    Option 2. This is one of the principles underlying the .NET Framework itself: to provide a set of managed libraries that are consistent regardless of the shape of the unmanaged APIs they wrap.

    Your wrapper should follow the .NET Class Library Design Guidelines as far as possible. You’ll know you’re on the right track when your managed wrapper starts to feel like pure C# instead of a layer over an unmanaged DLL.

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

Sidebar

Related Questions

I need your opinion on this because I have read a lot of different
I need a real DBA's opinion. Postgres 8.3 takes 200 ms to execute this
This is a subjective question, but I need opinions. I have a WinForms C#
I would like to know other people's opinion on the following style of writing
Need your opinion on the edited part of this question i asked on stackoverflow.
I'mm writing gtk code. I often have short callbacks that don't need to be
.NET developers out there! Need your opinion here! I am now using Visual Assist
need ask you about some help. I have web app running in Net 2.0.
Need a function like: function isGoogleURL(url) { ... } that returns true iff URL
I am writing an Apache module in C++. I need to store the common

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.