Quantcast
Viewing all articles
Browse latest Browse all 18858

STA error when opening WPF window from Winform window

App.xaml is the startup point for the application (build action is ApplicationDefinition). This opens a WinForm window, that eventually opens a WPF window (when a menu item is clicked). At this point, the application crashes, by the WPF window constructor, with

The calling thread must be STA, because many UI components require this.

I have tried using a Main method as the startup point with [STAThread] (and setting the build action of App.xaml to Page), but it didn't help. App.ApplicationStartup has [STAThread]. Note that the project used to be just WinForms, and WPF was added later. Everything is done on the main UI thread.

Does anyone know of a possible solution? Hopefully that does not involve creating additional threads.

Thanks


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>