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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:16:00+00:00 2026-06-13T01:16:00+00:00

I have a C++/CLI DLL that uses some managed code (written in C#). I

  • 0

I have a C++/CLI DLL that uses some managed code (written in C#). I want to export a pure C function from the DLL – it will be called from unmanaged code using LoadLibrary and GetProcAddress.

In the exported function I just need to create an instance and call one method of a C# class. So I tried this:

extern "C" __declspec( dllexport ) int __stdcall DoWork(
       const wchar_t* Param1,
       int Param2,
       void* Param3)
{
    WorkerNamespace::ManagedClass1 worker;
    return worker.DoWork( gcnew String(Param1), Param2, IntPtr( Param3 ) );
}

It compiles fine but when I do a dumpbin CompiledDll.dll /exports there are no exported functions.

I tried adding #pragma unmanaged before the function declaration but then I get errors for using managed types inside the body.

If I replace the body of the function with an empty stub (just return 1;) and with #pragma unmanaged, the function still doesn’t show up in dumpbin. So what am I doing wrong? How do I export a C function from a C++/CLI Class Library project?

  • 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-06-13T01:16:00+00:00Added an answer on June 13, 2026 at 1:16 am

    Must have been a configuration issue. I created a new project using the Empty project template, changed

    Configuration Type to Dynamic Library (.dll)

    Common Language Runtime Support to Common Language Runtime Support (/clr)

    in General Configuration and added a reference to System.Core and my C# assembly in Common Properties and it works now.

    I also added a .DEF file to handle name mangling (the def file’s name should, of course, be set in Linker -> Input -> Module Definition file).

    LIBRARY
    EXPORTS
    DoWork
    

    Hope that helps someone else.

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

Sidebar

Related Questions

we have a C++ Win32 DLL that reads data from Excel. The application uses
I have a custom plugin for 3ds Max that interfaces with some managed code
I have a C++ DLL (no code) that I want to expose to .NET
I have an unmanaged dll that contains a function to read a data from
I have a library written in C++/CLI and I want to open it up.
I'm attempting to call a method written in C++/CLI from C#. The C++/CLI code
I have a C# DLL that uses the XslCompiledTransform class for xml manipulations. I
I have a native C++ DLL that uses COM ADO Recordsets and am in
I have a Visual Studio 2010 solution that contains C# (managed), C++/CLI (unmanaged) and
So I have this C .dll source code which I want to use in

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.