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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:26:58+00:00 2026-05-29T09:26:58+00:00

I have a DLL which contains unmanaged classes with methods. I’m trying to call

  • 0

I have a DLL which contains unmanaged classes with methods. I’m trying to call those methods from C++/CLI.

My reading has lead me to find that P/Invoke is used to do this. However, I can’t seem to find out how to make it work.

In the DLL, the following class is defined:

//Header:
namespace MathFuncs
{
    class MyMathFuncs
    {
    public:
        static __declspec(dllexport) double Add(double a, double b);
        static __declspec(dllexport) double Subtract(double a, double b);
        static __declspec(dllexport) double Multiply(double a, double b);
        static __declspec(dllexport) double Divide(double a, double b);
    };
}

//Source:
namespace MathFuncs
{
    double MyMathFuncs::Add(double a, double b) {
        return a + b;
    }

    double MyMathFuncs::Subtract(double a, double b) {
        return a - b;
    }

    double MyMathFuncs::Multiply(double a, double b) {
        return a * b;
    }

    double MyMathFuncs::Divide(double a, double b) {
        if (b == 0) {
            throw new invalid_argument("b cannot be zero!");
        }
        return a / b;
    }
}

From what I’ve read, the following should declare a method in my C++/CLI code, which I can then call in my code:

class MyMathFuncs {
public:
[DllImport("TestDLL.dll")]
    static double Add(double a, double b);
};

Where “TestDLL.dll” is my DLL.

The error I get is at runtime. It says “Unable to find an entry point named ‘Add’ in DLL ‘TestDLL.dll'”.

What am I doing wrong? I’ve read through the MSDN articles on this, but I don’t understand it.

Thanks in advance for 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-29T09:26:58+00:00Added an answer on May 29, 2026 at 9:26 am

    Did you create a DEF file for your native DLL?

    • http://msdn.microsoft.com/en-us/library/d91k01sh(v=vs.80).aspx

    Dumpbin may also help. See what the DLL is exporting:

    • http://msdn.microsoft.com/en-us/library/c1h23y6c(v=vs.71).aspx
    • http://msdn.microsoft.com/en-us/library/30e78zd0(v=vs.71).aspx
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dll called utilities which contains some helper methods and I want
I have an unmanaged dll that contains a function to read a data from
I have a DLL which contains a class with static members . I use
Hi I have a plugin.dll which contains this all npp functions I have embeded
I have a .NET dll which needs to read it's config settings from it's
I have a C++ dll which implements several COM interfaces, that I'm trying to
I have a dll which contains this function: int __stdcall PrnText(char *printtext); In Windows
We currently have a XAP file which contains Foo.dll, and another XAP file (with
If I have a an app which relies on a .dll which contains my
That's what I wanna achieve : There will be dll which contains only methods

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.