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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:29:02+00:00 2026-05-13T13:29:02+00:00

I created a C++/CLI assembly that creates a wrapper around native C++ code. The

  • 0

I created a C++/CLI assembly that creates a wrapper around native C++ code. The resource compiles and the assembly loads fine into my C# project when I add it as a resource. I can access my objects and intellisense from within my application, but when attempting to build, it crashes with the exception:

BadImageFormat

Could not load file or assembly
‘MyCLI, Version=1.0.3680.28432,
Culture=neutral, PublicKeyToken=null’
or one of its dependencies. An attempt
was made to load a program with an
incorrect format.

I load it into my form load event:

MyCLI.myCLI z;

… and when I compile, it crashes on this line in my main constructor in C#

Application.Run(new Form1());

Does anyone have an idea of what could be causing this exception?

Thanks

  • 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-13T13:29:02+00:00Added an answer on May 13, 2026 at 1:29 pm

    You are trying to run this code on a 64-bit operating system. Your C# code will get nicely compiled to 64-bit machine code. But you’ll hit the wall when it tries to load a 32-bit C++/CLI assembly.

    In the C# project, use Project + Properties, Application tab, Platform Target = x86. Creating a 64-bit version of your C++/CLI assembly is possible too, use Build + Configuration Manager. Using Platform Target is the better solution.

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

Sidebar

Related Questions

I have created a C++ CLI wrapper for native C++ code, which in turn
I need to create a C++/CLI mixed assembly that can schedule future calls into
I am writing a wrapper around C DLL in C++/CLI so that it can
I have a C++/CLI assembly that wraps a native 32-bit dll. The assembly is
I have created a C++/CLI wrapper around some library. When I inspect the compiled
I want to use a .dll created with c++/cli that includes normal c code
I am trying to create a pure MSIL assembly from a C++/CLI project using
I am having a problem with a C++/CLI mixed mode DLL that I created.
I'm making a C++/CLI wrapper for a C++ class, but the DLL created by
In some C++/CLI code I have a native class which has a factory method

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.