System.BadImageFormatException: Could not load file or assembly. Format of the executable (.exe) or library (.dll) is invalid

166 views Asked by At

So I'm making a Microsoft Flight Simulator plugin that gets some data from the sim and makes something with it, doesn't really matter as i'm not there yet...

Im using SimConnect to connect with the simulator, a first-party SDK from Microsoft, but I cant fully understand the docs.

I've looked online and its pretty much always top change the architecture to x86, so I've done that (I think) Visual Studio but it didn't solve it.

Here are the docs: https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/SimConnect_SDK.htm

and the code:

using Microsoft.FlightSimulator.SimConnect;
using System.Runtime.InteropServices;


internal class Program
{
    SimConnect? simConnect;
    private readonly IntPtr handle = new IntPtr(0);

    void Run()
    {
        const int WM_USER_SIMCONNECT = 0x0402;
        try
        {
            simConnect = new SimConnect("Managed Data Request", handle, WM_USER_SIMCONNECT, null, 0);
            // You can perform other operations with simConnect here.
        }
        catch (COMException ex)
        {
            Console.WriteLine(ex.Message);
        }

        if (simConnect != null)
        {
            simConnect.Dispose();
            simConnect = null;
        }
    }

    static void Main(string[] args)
    {
        // Create an instance of the Program class
        Program program = new Program();

        // Call the Run method to execute its code
        program.Run();
    }
}

Thanks for the help!

I've looked at the docs, but it wasn't useful/could understand the useful part I've looked online and its pretty much always top change the architecture to x86, so I've done that (I think) Visual Studio but it didn't solve it.

0

There are 0 answers