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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:26:07+00:00 2026-05-23T10:26:07+00:00

I have 3 projects in one solution. I have : a native C++ dll,

  • 0

I have 3 projects in one solution.

I have :

  • a native C++ dll,
  • a C# Winform,
  • and a proxy C++/CLI without pure mode to do the link between the 2 others projects (and use the native function in the managed code in C#)

So when I launch the application all work. But when I push the button "Generer" in my winform wich execute the function NativeMethod::Test() of the C++/CLI that it crash and I have this pop-up message :

An unhandled exception of type
‘System.BadImageFormatException’
occurred in System.Windows.Forms.dll

Additional information: Could not load
file or assembly
‘EngineInterfaceWrapper.dll’ or one of
its dependencies. n’est pas une
application Win32 valide. (Exception
from HRESULT: 0x800700C1)

When I go in project proprieties in Conf. Properties -> Linker -> Advanced : Target Machine, it’s set with the value "MachineX86" for my C++ native and managed DLL and my WinForm is in X86 too. I tired many configurations but it don’t work.

Edit:

The problem is may be the header "TradeEngine.h"" in the C++/CLI header : EngineInterfaceWrapper.h. Because when I unlink the native C++ Dll (and deleting all code in the CLI wrapper) if I build the solution it will work but if "#include "TradeEngine.h"" is always in the CLI header, I will have the same error. Do you have an idea?

Code :

native C++

TradeEngine.h

#ifdef TRADEENGINE_EXPORTS
#define SYMBOL_DECLSPEC __declspec(dllexport)
#define SYMBOL_DEF
#else
#define SYMBOL_DECLSPEC __declspec(dllimport)
#define SYMBOL_DEF      __declspec(dllimport)
#endif

EXTERN_C SYMBOL_DECLSPEC void __stdcall Test(void);

TradeEngine.cpp

SYMBOL_DECLSPEC void __stdcall Test(void)
{
}

C++/CLI

EngineInterfaceWrapper.h

#pragma once

#include "TradeEngine.h"

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

namespace EngineInterfaceWrapper {

    public ref class NativeMethod
    {
    public:
        static void AjoutColonneDifferenceCourtClotureOuvertureReelle(void);
        static void Test();
    };
}

EngineInterfaceWrapper.cpp

#pragma region Includes
#include "stdafx.h"
#include "EngineInterfaceWrapper.h"
using namespace EngineInterfaceWrapper;

#include <msclr/marshal.h>
using namespace msclr::interop;
#pragma endregion

void NativeMethod::Test()
{
    ::Test();
}

C# Winform

Program.cs

namespace TradeInterface
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

Form1.cs

generer_Click() is the event launched by the button when the user click on Generer.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Runtime.InteropServices;
using EngineInterfaceWrapper;

namespace TradeInterface
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void generer_Click(object sender, EventArgs e)
        {
            NativeMethod.Test();
        }
    }
}

How can I fix that? If you need more info, tell me.

  • 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-23T10:26:07+00:00Added an answer on May 23, 2026 at 10:26 am

    One reason can be you are trying to load a native 32-bit dll in a 64-bit process. Make sure you have platform target set to x86 in your app to force your application to run inside WoW64.

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

Sidebar

Related Questions

I have a Solution with multiple projects. One project is my DataAccess project with
I have a customer who wants her local newspaper (.pdf) published as an native
I have a project in my solution which started life as a C# library
We have a product with ~15 solutions with each a number of projects. The
In my project I have two libraries that would currently result in a circular
I have worked in project for long time but after electricity has cut off
I'm about to start a new project which would allow users to navigate through
I must be losing my mind... After getting a test WCF hosted in a
While I continue to ponder this for the technical consequences that hitting 'compile' generates,
There is a tutorial video that introduces Spring MVC 3.0. In the demo-project they

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.