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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:17:48+00:00 2026-05-23T04:17:48+00:00

I have a unmanaged C++ dll for which I do not have access to

  • 0

I have a unmanaged C++ dll for which I do not have access to code but have all methods declarations for.

Lets for simplicity say that .h looks like this:

#include <iostream>

#ifndef NUMERIC_LIBRARY
#define NUMERIC_LIBRARY

class Numeric
{
    public:
        Numeric();
        int Add(int a, int b);
        ~Numeric();
};

#endif

and method implementation in .cpp file

int Numeric::Add(int a, int b)
{
    return (a + b);
}

I simply want to call the add function from C++ in my C# code:

namespace UnmanagedTester
{
    class Program
    {
        [DllImport(@"C:\CPP and CSharp Project\UnmanagedNumeric\Debug\numeric.dll", EntryPoint = "Add")]
        public static extern int Add(int a, int b);


        static void Main(string[] args)
        {
            int sum = Add(2, 3);
            Console.WriteLine(sum);

        }
    }
}

After trying to execute I have the following error:

Unable to find an entry point named ‘Add’ in DLL ‘C:\CPP and CSharp Project\UnmanagedNumeric\Debug\numeric.dll’.

I CAN NOT change C++ code. Have no idea what is going wrong.
Appreciate your help.

  • 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-23T04:17:49+00:00Added an answer on May 23, 2026 at 4:17 am

    Using PInvoke you can only call global functions exported from Dll. To use exported C++ classes, you need to write C++/CLI wrapper. This is C++/CLI Class Library project, which exposes pure .NET interface, internally it is linked to unmanaged C++ Dll, instantiates a class from this Dll and calls its methods.

    Edit: you can start from this: http://www.codeproject.com/KB/mcpp/quickcppcli.aspx#A8

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

Sidebar

Related Questions

I have a very simple DLL written in unmanaged C++ that I access from
I have an unmanaged C++ DLL which merely exports a single class (not COM...it's
I have a situation in which a managed DLL calls some unmanaged DLL. I
Here's my problem: I have an unmanaged dll that I made.I'm calling one of
I have a fortran (unmanaged code) dll as the calculation engine, and a C#
I have a simple application that loads an unmanaged dll and passes a few
I have an unmanaged DLL with a function that can run for a long
Here's some C# source code which implements an unmanaged DLL (advapi32). public void AddPrivileges(string
I have a vb.net dll which I imported in an unmanaged c++ project. I
I have a closed source unmanaged DLL coded in C++ that I wanted to

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.