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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:47:11+00:00 2026-05-24T23:47:11+00:00

I have a DLL that contains a class that inherits from another abstract C++

  • 0

I have a DLL that contains a class that inherits from another abstract C++ class defined as following:

class PersonInterface
{
public:
    virtual int __stdcall GetName() = 0;
};

The DLL exports a function that can be used in C# as following (following method is part of static class PersonManager):

[DllImport( "person.dll", CallingConvention = CallingConvention.Cdecl )]
public static extern bool GetPerson( out PersonInterface person  );

where PersonInterface is defined in C# class as following:

[StructLayout( LayoutKind.Sequential )]
public class PersonInterface
{
}

I can successfully retrieve the C++ class instance like this:

PersonInterface person;
bool retrieved = PersonManager.GetPerson( out person );

However, the retrieved object is not of any use until GetName method can be called.

What else needs to be done in order to be able to be able to invoke GetName method on retrieved person object?

string name = person.GetName();
  • 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-24T23:47:12+00:00Added an answer on May 24, 2026 at 11:47 pm
    • Compile your C++ DLL using /clr compiler option.
    • Write up a managed class using public ref class syntax, and have pointer to your native class in this class. Expose all methods from this managed class and forward all calls to your native class.
    • Import this DLL as assembly in your c# project and use this class as you would use any other .NET class.

    You need to compile only few source files using /clr flag, not all. Let all native source files be compiled as native. Your DLL will be linked to VC runtime DLL as well as .NET runtime DLL.

    There is lot to managed class, /clr, Interoperability/Marshalling, but at least get started.

    You may choose your favorite articles from here

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

Sidebar

Related Questions

I have a dll that contains a number of classes that all inherit from
I have a .NET class library (as a .dll file) and that library contains
I have a dll that contains a templated class. Is there a way to
I have an unmanaged dll that contains a function to read a data from
I have a dll that I'm working with, it contains a class foo.Launch. I
I have an MFC extension DLL that I've written. It contains derived classes of
If I have a Server/Client application that both reference the same DLL which contains
I have a DLL that I can use to pull the following information about
I have a dll that exports extern C __declspec(dllexport) int __stdcall Foo( void );
I have been provided with an unmanaged C++ DLL that contains several classes. I

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.