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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:10:51+00:00 2026-06-06T14:10:51+00:00

So I am trying to export a function in a DLL that was developed

  • 0

So I am trying to export a function in a DLL that was developed in C++ into a C# project. After digging around online and doing some book research as well I found a means to do so. However my exposure to this is limited and all my knowledge is self taut so I am sure that I messed something up somewhere.

I am exporting the function like so:

STDMETHODIMP __export DataSetpImpl::set_HeaderFile(BSTR Value)

and importing it as such:

public unsafe class test
{
  const string _dllLocation = "DllPath.dll";
  [DLLImport(_dllLocation, CallingConvention = CallingConvention.stdCall)]
  [return: MarshalAs(UnmanagedType.Bstr)]
  public static extern string set_HeaderFile([MarshalAs(UnmanagedType.BStr)] String path);
}

then call it in the application as followes:

test.set_HeaderFile(@"C:\temp\SomeHeaderFile.hdz");

everything builds correctly and links up just fine… the issue appears when the application hits the above call. It throws and error saying:

Unable to find an entry point named 'set_HeaderFile' in DLL 'DLLPath.dll'.

any ideas on what I am doing wrong? Also please keep in mind my knowledge on this subject if very limited, I am just going off what I could find online and in notes around the office.

  • 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-06T14:10:53+00:00Added an answer on June 6, 2026 at 2:10 pm

    This way you can only import non-class member functions.

    The name “set_HeaderFile” in your case is mangled into something like “DataTableImpl$$set_HeaderFile@4” and even if it is declared as static, the CLR won’t find this in your .dll file using the name “set_HeaderFile”.

    You can make a workaround.

    Say you have a

    DataSetpImpl* g_Instance;
    

    Then write a function

    LONG __stdcall mySetHeaderFile(BSTR Val)
    {
        return g_Instance->set_HeaderFile(Val);
    }
    

    and then in C# you can access it.

    [DLLImport(_dllLocation, CallingConvention = CallingConvention.stdCall, EntryPoint="mySetHeaderFile")]
    public static extern Int32 set_HeaderFile([MarshalAs(UnmanagedType.BStr)] String path);
    

    Returning BSTRs also require some wrapping using the Marshalling. See this: http://msdn.microsoft.com/en-us/library/7b620dhe.aspx

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

Sidebar

Related Questions

I'm trying to export an Excel database into .txt (Tab Delimited), but some of
I'm trying to create a DLL that exports a function called GetName. I'd like
I was trying to export a simple test function for a dll to work
I'm trying to write a dll that will store some values passed to it
Im trying to export data from a database into a set format so that
I am trying to use the Soundcloud API to implement an integrated export function
I'm trying to export a profile from WAS 6.1 so that I can give
I'm trying to export the data that is shown in plot(yi) using wavwrite. When
I'm trying to export a global variable from a DLL. Foo.h class Foo {
I have a DLL with one single function That gets five doubles and one

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.