A simple library to connect and work with SimConnect, a library allowing to communicate with Flight Simulators (e.g., FS2020).
The aim of this library is to provide a simple interface to work with FS2020 over .NET/C# without no deep knowledge of SimConnect. On the other side, only the basic operations are supported. This library is not covering all the possibilities of original SimConnect library.
The library needs Windows .NET 6.0 runtime to be installed (it is included in Windows 10+ instalation by default).
Download the release and unpack it to obtain .DLL and other files.
Follow carefully all the following steps!
To add library to your project:
- Ensure project is .NET 6.0 (or higher)
- Ensure project target OS is Windows and version 7.0, targeted for
x64build. - Ensure project uses WPF (in
.csproj, add<UseWPF>true</UseWPF>) *) - Add references/dependencies into the project:
Microsoft.FlightSimulator.SimConnect.dllESimConnect.dllESystem.dll.
- Ensure
SimConnect.dllis copied in the output/startup directory and not referenced as a dependency.
If unsure, just check any example project in this repository.
*) - for unknown reason, this is required for some project. Otherwise, you may get an issue with linking WindowBase.dll of version 4 vs 6 together. So far, I have no clue what is causing this.
A simple example application ESimConnectDemo is available in the project.
When running FS2020, start ESimConnectDemo.exe. In the window, select Connect/Disconnect button. In SimVars tab, enter SimVar name and press Add. You should immediatelly see the value of the SimVar in the window.
Note: For specific SimVar names, look to FS202 SimVar documentation. At the beginning, you can try to enter PLANE ALTITUDE SimVar.
For more detailed info, see ESimConnectDemo or ESimConnectTest projects for inspiration.
There are other tutorials in this repository:
- How to listen to SimEvents - see 'Tutorials/ESimConnectSimEvent' project and tutorial.
- How to read out SimVar value - see 'Tutorials/ESimConnectSimVarRead' project and tutorial.
- How to read out multiple SimVars via struct at once - see 'Tutorials/ESimConnectSimVarStruct' project and tutorial.
- How to use extenders:
- How to open connection in async way - 'Tutorials/OpenAndSimTimeExtendersExample' project and tutorial.
- How to get notified when sim second elapses - 'Tutorials/OpenAndSimTimeExtendersExample' project and tutorial.
- How to cache SimVar value to read it from different modules - 'Tutorials/ValueCacheExtenderExample' project and tutorial.
- How to cache multiple SimVar values in an object to ready them at once - 'Tutorials/TypeCacheExtenderExample' project and tutorial.
If anything does not work, feel free to report it as an issue. Please provide as many details as possible.
Q: On startup, an error occurs: System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.FlightSimulator.SimConnect, Version=11.0.62651.3, Culture=neutral, PublicKeyToken=baf445ffb3a06b5c'.
A: There are either Microsoft.FlightSimulator.SimConnect.dll or
SimConnect.dll file(s) missing in the working directory, OR your project is not targeted for x64 build.
See LICENSE file.
Thanks to RandFailuresFS2020 original repo for being an initial motivation and a study source.
Thanks to George Barlow for his help with resolving unregistering issues.
Marek Vajgl https://github.com/Engin1980/ESimConnect