WPF defines its own Main() method. How should I go about replacing it with my own Main method that (normally) opens the WPF MainWindow (e.g. to add a non-WPF scripting mode via command-line arguments)?
WPF defines its own Main() method. How should I go about replacing it with
Share
Some examples depict changing App.xaml’s Build Action from
ApplicationDefinitiontoPageand writing your ownMain()that instantiates theAppclass and calls itsRun()method, but this can produce some unwanted consequences in the resolution of application-wide resources in App.xaml.Instead, I suggest making your own
Main()in its own class and setting the Startup Object to that class in the project properties:I do this to take advantage of some
AppDomainevents that must be subscribed to before anything else happens (such asAssemblyResolve). The unwanted consequences of setting App.xaml toPagethat I experienced included myUserControlViews (M-V-VM) not resolving resources held in App.xaml during design-time.