C# App Error in other pcs "could not load file or assembly "Microsoft.FlightSimulator.SimConnect.dll"

Hey there

-C# App with simconnect
-App working ok on my pc, from Visual Studio 2019 and after compile and install in my pc, all work ok
-After installing it on any other pc and trying to start I get the error
-Same error that occurs in my pc if I delete simconnect.dll in app main folder with .exe file, but the file simconnect.dll is there in the main folder on the other pc too

Any ideas about that?

Error:

Unhandled exception has occurred in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will close immediately

Could not load file or assembly “Microsoft.FlightSimulator.SimConnect.dll” or one of its dependencies. The specified module could not be found."

Err Details:

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.FlightSimulator.SimConnect.dll’ or one of its dependencies. The specified module could not be found.
File name: ‘Microsoft.FlightSimulator.SimConnect.dll’
at MyApp.Form1.DefWndProc(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

According to this(https://devsupport.flightsimulator.com/questions/10841/microsoftflightsimulatorsimconnectdll-vs-simconnec.html) you need both Microsoft.FlightSimulator.Simconnect.dll and simconnect.dll to be present.

1 Like

both files are already in to the main folder with .exe file

Start by using the Fusion Log to see why the CLR can’t bind to the assembly. That should give you enough information to understand what the problem is.

Using Fusion Log in my pc i get this about Microsoft.FlightSimulator.SimConnect.dll

*** Assembly Binder Log Entry (12/30/2022 @ 4:00:25 PM) ***

The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Users\usr1\source\repos\MyAppV1\MyApp\bin\x64\Release\MyApp.exe
— A detailed error log follows.

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.FlightSimulator.SimConnect, Version=11.0.62651.3, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Users/usr1/source/repos/MyAppV1/MyApp/bin/x64/Release/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MyApp.exe
Calling assembly : MyApp, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null.

LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\usr1\source\repos\MyAppV1\MyApp\bin\x64\Release\MyApp.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/usr1/source/repos/MyAppV1/MyApp/bin/x64/Release/Microsoft.FlightSimulator.SimConnect.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Users\usr1\source\repos\MyAppV1\MyApp\bin\x64\Release\Microsoft.FlightSimulator.SimConnect.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Microsoft.FlightSimulator.SimConnect, Version=11.0.62651.3, Culture=neutral, PublicKeyToken=null
LOG: Binding succeeds. Returns assembly from C:\Users\usr1\source\repos\MyAppV1\MyApp\bin\x64\Release\Microsoft.FlightSimulator.SimConnect.dll.
LOG: Assembly is loaded in default load context.

Since the CLR is binding to the interop assembly properly, the problem is likely due to one of the native dll dependencies not being found (or that simconnect.dll itself isn’t getting found for some reason). I’d start with using dumpbin /imports on the native simconnect.dll and see what dependencies it has and whether you can locate them. Alternatively, you can use gflags to take a Loader Snapshot to see what is going on. Because loader snaps can be large, you may want to test with a very simple C# application rather than your actual application.

dumpbin /exports simconnect.dll throw this

File Type: DLL

Section contains the following exports for SimConnect.dll

00000000 characteristics
FFFFFFFF time date stamp
    0.00 version
       1 ordinal base
      79 number of functions
      79 number of names

ordinal hint RVA      name

      1    0 00005320 SimConnect_AICreateEnrouteATCAircraft
      2    1 00005560 SimConnect_AICreateNonATCAircraft
      3    2 00005730 SimConnect_AICreateParkedATCAircraft
      4    3 00005940 SimConnect_AICreateSimulatedObject
      5    4 00005AA0 SimConnect_AIReleaseControl
      6    5 00005B70 SimConnect_AIRemoveObject
      7    6 00005C40 SimConnect_AISetAircraftFlightPlan
      8    7 00005D80 SimConnect_AddClientEventToNotificationGroup
      9    8 00005E70 SimConnect_AddToClientDataDefinition
     10    9 00005F80 SimConnect_AddToDataDefinition
     11    A 00006150 SimConnect_AddToFacilityDefinition
     12    B 00006270 SimConnect_CallDispatch
     13    C 000062C0 SimConnect_CameraSetRelative6DOF
     14    D 000063F0 SimConnect_ClearClientDataDefinition
     15    E 000064E0 SimConnect_ClearDataDefinition
     16    F 000065D0 SimConnect_ClearInputGroup
     17   10 000066C0 SimConnect_ClearNotificationGroup
     18   11 000067B0 SimConnect_Close
     19   12 00006800 SimConnect_CompleteCustomMissionAction
     20   13 000068D0 SimConnect_CreateClientData
     21   14 000069C0 SimConnect_ExecuteMissionAction
     22   15 00006A90 SimConnect_FlightLoad
     23   16 00006BA0 SimConnect_FlightPlanLoad
     24   17 00006CB0 SimConnect_FlightSave
     25   18 00006EC0 SimConnect_GetLastSentPacketID
     26   19 00006F00 SimConnect_GetNextDispatch
     27   1A 00006F50 SimConnect_InsertString
     28   1B 00007080 SimConnect_MapClientDataNameToID
     29   1C 000071A0 SimConnect_MapClientEventToSimEvent
     30   1D 000072C0 SimConnect_MapInputEventToClientEvent
     31   1E 00007440 SimConnect_MenuAddItem
     32   1F 00007580 SimConnect_MenuAddSubItem
     33   20 000076D0 SimConnect_MenuDeleteItem
     34   21 000077C0 SimConnect_MenuDeleteSubItem
     35   22 00007890 SimConnect_Open
     36   23 00007A40 SimConnect_RemoveClientEvent
     37   24 00007B10 SimConnect_RemoveInputEvent
     38   25 00007C30 SimConnect_RequestClientData
     39   26 00007D60 SimConnect_RequestDataOnSimObject
     40   27 00007E90 SimConnect_RequestDataOnSimObjectType
     41   28 00007F90 SimConnect_RequestFacilitiesList
     42   29 00008060 SimConnect_RequestFacilitiesList_EX1
     43   2A 00008130 SimConnect_RequestFacilityData
     44   2B 000082D0 SimConnect_RequestFacilityData_EX1
     45   2C 00008470 SimConnect_RequestNotificationGroup
     46   2D 00008560 SimConnect_RequestReservedKey
     47   2E 00008760 SimConnect_RequestResponseTimes
     49   30 00008AA0 SimConnect_RetrieveString
     50   31 00008B20 SimConnect_SetClientData
     51   32 00008C50 SimConnect_SetDataOnSimObject
     52   33 00008D90 SimConnect_SetInputGroupPriority
     53   34 00008E60 SimConnect_SetInputGroupState
     54   35 00008F30 SimConnect_SetNotificationGroupPriority
     55   36 00009000 SimConnect_SetSystemEventState
     56   37 000090D0 SimConnect_SetSystemState
     57   38 00009290 SimConnect_SubscribeToFacilities
     58   39 00009360 SimConnect_SubscribeToFacilities_EX1
     59   3A 00009450 SimConnect_SubscribeToSystemEvent
     60   3B 00009570 SimConnect_Text
     61   3C 00009690 SimConnect_TransmitClientEvent
     62   3D 00009790 SimConnect_TransmitClientEvent_EX1
     63   3E 000098D0 SimConnect_UnsubscribeFromSystemEvent
     64   3F 000099C0 SimConnect_UnsubscribeToFacilities
     65   40 00009AB0 SimConnect_UnsubscribeToFacilities_EX1
     66   41 00009BA0 SimConnect_WeatherCreateStation
     67   42 00009D80 SimConnect_WeatherCreateThermal
     68   43 00009F10 SimConnect_WeatherRemoveStation
     69   44 0000A030 SimConnect_WeatherRemoveThermal
     70   45 0000A120 SimConnect_WeatherRequestCloudState
     71   46 0000A270 SimConnect_WeatherRequestInterpolatedObservation
     72   47 0000A370 SimConnect_WeatherRequestObservationAtNearestStation
     73   48 0000A460 SimConnect_WeatherRequestObservationAtStation
     74   49 0000A580 SimConnect_WeatherSetDynamicUpdateRate
     75   4A 0000A670 SimConnect_WeatherSetModeCustom
     76   4B 0000A740 SimConnect_WeatherSetModeGlobal
     77   4C 0000A810 SimConnect_WeatherSetModeServer
     78   4D 0000A8E0 SimConnect_WeatherSetModeTheme
     79   4E 0000A9F0 SimConnect_WeatherSetObservation

Summary

    1000 .data
    1000 .pdata
    4000 .rdata
    1000 .reloc
    1000 .rsrc
    B000 .text

Sorry, I typed dumpbin /exports, but I meant dumpbin /imports. You need to know what other dlls are being referenced.

1 Like

Yes!! That work!! i download those dll files in to the other pc and work!!! those dll files are

WS2_32.dll
SHLWAPI.dll
ADVAPI32.dll
USER32.dll
KERNEL32.dll  
SHELL32.dll
MSVCP140.dll
VCRUNTIME140.dll
VCRUNTIME140_1.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-heap-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
api-ms-win-crt-convert-l1-1-0.dll

Thankyou geoffda man you are the best!!!

Glad you got it sorted. Looks like you didn’t have the right c runtime installed on the problem machine.

1 Like