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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:04:00+00:00 2026-05-13T00:04:00+00:00

I am a bit confused about wrapping a c++ dll in c#. What kind

  • 0

I am a bit confused about wrapping a c++ dll in c#.
What kind of dll should i create? A normal dll or an mfc dll? Should i prefix every proto with “extern…” ? Should i write the functions in a def file?

My last effort was in vain, c# would crash with an error like “bad image format”, which means that the dll format is not correct?

Any help would be much appreciated.

Thanks in advance 🙂

  • 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-13T00:04:00+00:00Added an answer on May 13, 2026 at 12:04 am

    Are you using a 64-bit PC?

    “Bad image format” will occur on an x64 system if you try to mix x64 code and x86 code. This will happen if you write C# code (targeted to “Any CPU”, so it’ll jit-compile to x64 code) that calls an unmanaged DLL (that will probably be x86 by default).

    Two solutions to this are:

    • (Proper solution) Make sure the dll is compiled to target x64 so the whole program can run as a native 64-bit app, or
    • (Backwards compatibility solution) Force your whole application to run as an x86 app. In the C# project properties, change the Build “Any CPU” setting to “x86”.

    Otherwise, you should be able to create a normal COM dll (with or without MFC shouldn’t matter) and then just wrap it in an RCW (Runtime callable wrapper).

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

Sidebar

Related Questions

I am a little bit confused about 2 things. Firstly when I create an
I'm a bit confused about the right way to write a code. I read
I'm a bit confused about the streams... which is which? Simply, which stream should
I am a bit confused about socket programming in C. You create a socket,
I'm a bit confused about the size of my App! The folder and all
I am a bit confused about the 'rules' of when a TextView element displays
Perhaps I'm a bit confused about when to use the waitForPageToLoad command, but what
I'm a bit confused about how getters and setters in JPA annotated POJO classes
I'm a bit confused about how many controllers I need, and when I can
I'm a bit confused about inheritance under sqlalchemy, to the point where I'm not

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.