• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSX Getting Exceptions 9 and 29

Messages
9
Country
austria
I got a problem with the key event failures. Below the relevant piece of the c# code.
By clicking the button the electrical failure occurs and everything is well, but if I click it again I get exception 9 and exception 29 (Duplicate ID and Duplicate Event ID).
I think I have mistunderstood something here. Maybe somebody could have a look and give me some advice how to solve it...

Code:
// Enums
  enum FAILURES
  {
  KEY_TOGGLE_ELECTRICAL_FAILURE,
  KEY_TOGGLE_VACUUM_FAILURE
  }

  enum NOTIFICATION_GROUPS
  {
  GROUP_0
  }

// Eventhandler
  void simconn_OnRecvEvent(SimConnect sender, SIMCONNECT_RECV_EVENT data)
  {
  switch (data.uEventID)
  {
  case (uint)FAILURES.KEY_TOGGLE_ELECTRICAL_FAILURE:
  MessageBox.Show("ELECTRICAL");
  break;
  case (uint)FAILURES.KEY_TOGGLE_VACUUM_FAILURE:
  MessageBox.Show("VACUUM");
  break;
  }
  }

// Raise event
private void TriggerFailureEvent(FAILURES failureEvent)
  {
  string eventName = null;
  switch (failureEvent)
  {
  case FAILURES.KEY_TOGGLE_ELECTRICAL_FAILURE:
  eventName = "TOGGLE_ELECTRICAL_FAILURE";
  break;
  case FAILURES.KEY_TOGGLE_VACUUM_FAILURE:
  eventName = "TOGGLE_VACUUM_FAILURE";
  break;
  }
  simconn.MapClientEventToSimEvent(failureEvent, eventName);
  simconn.AddClientEventToNotificationGroup(NOTIFICATION_GROUPS.GROUP_0, failureEvent, true);
  simconn.SetNotificationGroupPriority(NOTIFICATION_GROUPS.GROUP_0, SimConnect.SIMCONNECT_GROUP_PRIORITY_HIGHEST);
  simconn.TransmitClientEvent(SimConnect.SIMCONNECT_OBJECT_ID_USER, failureEvent, 0, NOTIFICATION_GROUPS.GROUP_0, SIMCONNECT_EVENT_FLAG.GROUPID_IS_PRIORITY);
  }

// Button click
  private void TestFailure_Click(object sender, EventArgs e)
  {
  // DEBUGGING FUNCTION
  TriggerFailureEvent(FAILURES.KEY_TOGGLE_ELECTRICAL_FAILURE);
  }
 
If you map multiple times you get exception 29 I think (DUPLICATE) so you do it just once when the application initializes for example. However, prior to closing the connection with SimConnect you should also disconnect the event from the group either with ClearGroupEvents or the other method that removes a single event from a group. Otherwise if you disconnect and reconnect to the same FLight Simulator session (i.e. you have not quit the simulator) then you will also get the duplicate exception.
 
Back
Top