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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:45:01+00:00 2026-05-23T23:45:01+00:00

I have a DLL made in C++ that is then used in a C#

  • 0

I have a DLL made in C++ that is then used in a C# program. the C# program references the DLL and i call the classes and can use the functions defined in the DLL.

Now i want to add other functions to the DLL so i can run C++ code in C#. I Follow the example of how the other functions in the DLL are defined; .h and .cpp and i create a new function that executes code. I put it in the same places as the previously define functions, but when i put the DLL in my C# code my function is not there. when i create an instance of the DLL class my function is not a part of it.

I put it in the .h as a public function of the class and gave it code to run in the .cpp but its not found.

Why can’t my C# program see the function i made even though its following the same suite as the other functions?

UPDATE

code.h:

#pragma once

#include <windows.h>
#include <PvDisplayWnd.h>
#include <vfw.h>
#include "NPvResult.h"
#include "NPvDeviceInfo.h"
#include "NPvBuffer.h"
#include <string>

using namespace System;
using namespace System::Runtime::InteropServices;

public ref class NPvDisplayWnd
{
public :
    NPvDisplayWnd();
    bool Handle();
    NPvResult^ ShowModeless(long locx, long locy, long x, long y);
    NPvResult^ ShowModal();
    NPvResult^ NPvDisplayWnd::Create();
    int^ Display( NPvBuffer^ aBuffer, int^ x);
    NPvResult^ Work( const std::string afilename, unsigned short asizex, unsigned short asizey, unsigned short aBPP, double aFPS);
    NPvResult^ Close();
    NPvResult^ DoEvents();
}

code.cpp:

#include "NPvDisplayWnd.h"

NPvDisplayWnd::NPvDisplayWnd(){code}
NPvResult^ NPvDisplayWnd::Create(){code}
bool NPvDisplayWnd::Handle()
NPvResult^ NPvDisplayWnd::ShowModeless(long locx, long locy, long x, long y){code}
NPvResult^ NPvDisplayWnd::ShowModal(){code}
int^ NPvDisplayWnd::Display( NPvBuffer^ aBuffer, int^ x){code}
NPvResult^ NPvDisplayWnd::DoEvents(){code}
NPvResult^ NPvDisplayWnd::Work( const std::string aFileName, unsigned short aSizeX, unsigned short aSizeY, unsigned short aBPP, double aFPS){code}
NPvResult^ NPvDisplayWnd::Close(){code}

The function that i added was the Work() function. if i build this and place it in my C# code, it sees all the functions except work. To make sure i was using the right .dll, i changed the name of ShowModeless() to ShowModeless__F() and rebuilt it and added it to my C# and the change carried over, but i still didn’t see my Work() function.

  • 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-23T23:45:01+00:00Added an answer on May 23, 2026 at 11:45 pm

    On Windows, you must explicitly export symbols in order for users to be able to access them via DLLs. This is done using the __declspec(export) syntax. This is needed during compilation and linking of the DLL.


    Now that we know you’re using C++/CLI instead of regular C++, we can see a problem. Work takes a std::string. But Work is intended to be a managed function, and managed code cannot take a std::string as a parameter. You need to take a managed string type instead.

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

Sidebar

Related Questions

So I have made a .dll containing some methods that I wish to use
Here's my problem: I have an unmanaged dll that I made.I'm calling one of
I have DLL and application that will call some function in this dll. For
I have a C# class that I've made ComVisible so that it can be
I have a dll that I have made that works perfectly. I need to
I have a function inside a dll that I would like to call from
I have made a dll that compiles fine in 32bit mode, but when compiling
I have a shared reporting dll that is used in both windows and web.
I have an ASP.Net application that references a DLL which contains a singleton. The
I have a DLL made in C#, this DLL contains some clases like Creator.

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.