CsSimConnect / CsSimConnect

Apache License 2.0
10 stars 8 forks source link

SimConnect header etc not specified #2

Open Dragonlaird opened 3 years ago

Dragonlaird commented 3 years ago

The form appeared, clicked the sliding button to connect to MSFS2020 and it raised an exception:

System.DllNotFoundException
  HResult=0x80131524
  Message=Unable to load DLL 'CsSimConnectInterOp.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)
  Source=CsSimConnect
  StackTrace:
   at CsSimConnect.SimConnect.CsConnect(String appName, IntPtr& handle)
   at CsSimConnect.SimConnect.Connect() in C:\Users\drago\Source\Repos\CsSimConnect\CsSimConnect\SimConnect.cs:line 65
   at CsSimConnectUI.MainWindow.ToggleConnection(Object sender, RoutedEventArgs e) in C:\Users\drago\Source\Repos\CsSimConnect\CsSimConnectUI\MainWindow.xaml.cs:line 112
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run()
   at CsSimConnectUI.App.Main()

I'm not 100% certain of the cause, but I suspect the SimConnect.dll can't be found/used, as it is likely referencing files on your local PC instead of either embedding them in the solution or referencing the required files using, did you use the Environment Variable when specifying the location?

image

bert-laverman commented 3 years ago

Actually, it is built in the CsSimConnectInterOp project, but that is an unmanaged C++ project. After building the Solution, CsSimConnect.dll will be in "./x64/Debug/CsSimConnectInterOp.dll" or "./x64/Release/CsSimConnectInterOp.dll".

tml1024 commented 3 years ago

I had the same issues, had to add the SDK include and lib/static directories manually. The DLL problem I (for now) got around by setting PATH to include the directory where the CsSimConnectInterOp.dll had been put and running CsSimConnectUI.exe manually from the command line... I haven't really use Visual Studio much lately (and especially not for C#), so I couldn't quickly figure out how to modify the PATH that is used while running the app from VS. Probably it is trivial;)

bert-laverman commented 3 years ago

As soon as the functionality starts becoming useful I'l build releases, so you won't have to do the build yourself. Will try to see if I can get a certificate to sign the executables.

tml1024 commented 3 years ago

Sure, but from my point of view the very point is to build it myself, to be able to debug it, etc, to be able to contribute, and to perhaps eventually incorporate the same ideas in my own code. Do you happen to know whether MSFS WASM modules can also be built from C#, or does it have to be C++? (I actually know C++ better than C# at the moment, as I haven't had to use C# for anything work-related, but I can't say I would prefer C++...)

bert-laverman commented 2 years ago

Sorry to be late in answering this. No, I think that is not possible due to all the dependencies. Remember, the WASM usage by Asobo is only because of the multi-platform aspect: Windows as well as X-Box. Generating WASM would require all the dependencies (NuGet packages used) to be available on the X-Box and some of them are Windows only.

The root cause is that there is not much interest to provide independent alternatives to "standard" Microsoft libraries, of which a large number are Windows-specific.

So, for now, WASM is C++ only.