SimConnect + WASM combined project using VS2019

Chapter 2: Setting up the environment

In Visual Studio you create a solution that contains 1 or more projects. As I explained in Chapter 1, I need 2 projects.

image

The below steps will explain some specifics of each project.

  1. SimConnectWasmHUB

This is the SimConnect Client application written in C#. I based it on a "Windows Form App (.NET Framework) and used .NET Framework 4.7.2.

image

If you want to make use of the SimConnect SDK, you have to include the following namespace in your sourcefile:

using Microsoft.FlightSimulator.SimConnect;

This is the C# wrapper of the SimConnect dll. To make the using statement work, you first need to copy the Microsoft.FlightSimulator.SimConnect.dll from C:\MSFS SDK\SimConnect SDK\lib\managed to your project (I copy it where my source files of my projects are located). Be aware that [C:\MSFS SDK] is where my SDK is installed, and can be different on your computer.

Once this file is copied, you have to include it as a reference in your project.

image

In the next screen you go to “Browse” and use the “Browse…” button to locate the dll file you just copied. Press ok to add the reference. Now the above “using” statement should work.

But the C# wrapper makes use of the real SimConnect dll. As instructed in the SDK documentation, the best way is to make sure that your target directory includes a copy of “SimConnect.dll”. A way to do that automatically is to add it as a file in your project, and make sure that it is always copied to your target directly.

Make sure you search for “Executable Files (.exe,.dll,*.ocx)”, and select the file from “C:\MSFS SDK\SimConnect SDK\lib\SimConnect.dll”. After that, select the SimConnect.dll file in your project, and in its properties change to “Copy if newer”.

image

SimConnect is only working with 64-bit targets. If your target platform shows “Any CPU”, you can change it with the Configuration Manager of your solution by creating a new “Active solution platform” and make it “x64”.

Now your project is ready to use SimConnect.

  1. WASM module

You can create a separate solution for your WASM project, but I added it in the same. You can easily do that by right clicking on your existing solution and select “Add / New project…”.

If you have installed the SimConnect SDK, then you will be able to select some special project types made for Microsoft Flight Simulator. Select the MSFS WASM Module.

image

Once the WASM project is added, then you have to makes sure that it is build when you “Rebuild Solution”. You can do that in the Configuration Manager.

First test build

Now it’s a good time to do a first test build (menu Build / Rebuild Solution). If you get the below result, you’re good!

========== Rebuild All: 2 succeeded, 0 failed, 0 skipped ==========

Don’t worry if you get a lot of Warnings and Messages in the “Error List”. I have the feeling that IntelliSense struggles a lot with the WASM project - I’m even getting 3066 Errors, although my build is successful. But I could get rid of all of them by selecting “Build Only”, which is ignoring the IntelliSense errors.

image

Goto Chapter 3: Connection with SimConnect

8 Likes