SimConnect OnRecvSimobjectData Event Not Firing in .NET 8 WinForms Project

Hi, I’m developing a .NET 8 WinForms application that connects to MSFS using SimConnect. The connection is successful, and SimConnect.dll loads without errors. However, the Instance.OnRecvSimobjectData event handler never fires, so I can’t receive telemetry data.

What I’ve tried:

  • Registered the data definition and struct for aircraft telemetry.
  • Requested periodic data for the user aircraft (SIMCONNECT_OBJECT_ID_USER).
  • Subscribed to OnRecvSimobjectData before requesting data.
  • Added exception logging (OnRecvException), but no exceptions are reported.
  • Used message ID 0x0402 for SimConnect and the form.

Not too sure about these:

  • Confirmed MSFS is running and SimConnect connects (OnRecvOpen fires). I don’t ever see the debug message, but I do see another “success” message where I do new SimConnect(). :man_shrugging:
  • Verified the WinForms message loop is running and the form handle is valid.

Relevant code snippet:

Instance = new SimConnect("APPNAME", windowHandle, 0x0402, null, 0);
Instance.OnRecvOpen += (s, e) => Debug.WriteLine("SimConnect: connection opened.");
Instance.OnRecvSimobjectData += SimConnect_OnRecvSimobjectData;
Instance.OnRecvException += (s, e) => Debug.WriteLine($"SimConnect Exception: {e.dwException}");
SimConnectIntegration.Definitions.AircraftDataDefinition.Register(Instance);
Instance.RequestDataOnSimObject(
    SimConnectIntegration.Definitions.DEFINITIONS.AircraftData,
    SimConnectIntegration.Definitions.DEFINITIONS.AircraftData,
    SimConnect.SIMCONNECT_OBJECT_ID_USER,
    SIMCONNECT_PERIOD.SECOND,
    SIMCONNECT_DATA_REQUEST_FLAG.DEFAULT,
    0u, 0u, 0u
);

The handler:

private static void SimConnect_OnRecvSimobjectData(SimConnect sender, SIMCONNECT_RECV_SIMOBJECT_DATA data)
{
    Debug.WriteLine("--- SimConnect_OnRecvSimobjectData received ---");
    // ... dump data fields ...
}

Project structure:

MsfsClient/
├── Forms/
│   ├── MainForm.cs
│   ├── MainForm.Designer.cs
├── Models/
│   └── AircraftTelemetry.cs
├── Services/
│   ├── SimConnectService.cs
│   ├── SimConnectMapper.cs
│   └── NativeLibraryLoader.cs
├── SimConnectIntegration/
│   ├── Definitions/
│   │   └── AircraftDataDefinition.cs
│   ├── Structs/
│   │   └── AircraftDataStruct.cs
├── MsfsClient.csproj

What could prevent OnRecvSimobjectData from firing, even though SimConnect allegedly connects and no exceptions are reported? Thank you for any guidance.

Where/are you calling SimConnect.ReceiveMessage() ?
https://docs.flightsimulator.com/msfs2024/html/6_Programming_APIs/SimConnect/Programming_SimConnect_Clients_Using_Managed_Code.htm

Hiya Max. Thank you for asking that question. At first I had no clue what you meant by ReceiveMessage. I looked into it and with some GPTing I realized that I had the setup correct, but my messages weren’t making it to the WinForms message pump (WndProc). So; the app looked silent.

Once I added the WndProc method the messages started pouring in. :sob: I still have a lot to learn, but we’re off to a good start!

Glad that helped! The link I posted has an example of a WndProc implementation using ReceiveMessage() (there’s no way to link to just that part of the examples, sorry), but sounds like you have it covered now.

Cheers,
-Max

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.