Compiling a basic SimConnect template, get an error

I’ve quit trying to get Unity to work SimConnect, I can never get it working. I’ve started a C# WPF project, creating a basic SimConnect template that I can use for future projects so I don’t have write every line of code every single time.

It’s a simple project, a WPF window with two controls, a “test Connection” button, and an “Exit Application” button(I don’t really have code for Exit application yet). My code builds fine, and runs fine, but when I hit the “Test Connection” button(No matter whether I have MSFS running or not), I get this error:

System.BadImageFormatException: ‘Could not load file or assembly ‘Microsoft.FlightSimulator.SimConnect, Version=11.0.62651.3, Culture=neutral, PublicKeyToken=baf445ffb3a06b5c’. An attempt was made to load a program with an incorrect format.’

I’ve seen previous threads that say You need to put in Microsoft.FlightSimulator.Simconnect into the .exe folder. I’ve done that already, for both x64 and x86 architectures, but no luck.

Would appreciate a bit of help, thanks!

edit: How did I make some of the text larger and the other text normal? The only text I copied was the visual studio error lol

** VERY IMPORTANT** the SimConnect.dll is 64-bit! If you’re planning on creating projects yourself, make sure your project is also configured to compile in 64-bit

This post may help you get started and avoid some of the pitfalls often encountered with starting a new project in C# to use the SimConnect SDK.

I have read your thread a couple of times and it is very helpful. However I went into Project Properties and set platform target ->x64 bit but that still didn’t help.

Just read the part where it says “If you’re using a development IDE such as Visual Studio, the SimConnect.dll may not automatically copy to your compiled output folder, you may have to force it or do that manually.” Where do I go to set this?

edit: I did it as I said above, I think.

Another common problem. The easiest way to fix this is to use a Post Build script to copy the missing DLL and associated CFG file into your output folder.

You might be able to do it automatically by setting the Copy Always flag on the file properties

Unfortunately I’m not near my computers, otherwise I’d post a screenshot or 2, let me know if you’re still stuck and I’ll do that for you when I get back


I did the xcopy script into my post build event and that worked, I now have a working connection.

Thanks for your help!

One other thought just sprung to mind, are you referencing the SDK in it’s original folder or have you copied it to your project?

If you’ve copied the file locally, make sure the DLL is in the root of your project, not in a sub-folder.

Have you included a reference in your project to the correct copy (local or original location)?

Glad I could help

1 Like

… which was probably interpreted as „HTML formatted code“ by the forum software :wink: No worries!

1 Like

That would explain it as I’ve never done that before. Thanks!

Hi! Discourse (the forum software) uses “dashes” for formatting. If you remove the dashes after pasting text, it will be normal text:


I’ve edited your first post by removing those dashes. :wink:

Ah yes, I do remember typing in dashes at the time, that explains why.

Thanks for curing my ocd!

1 Like