c# - How to start the main class in WPF application? -


i newbie wpf.i have problem in developing wpf application want start class start object,after want show welcome form. when trying put main method in class set project properties startup object class. getting error "the calling thread must sta, because many ui components require this.".

how can resolve error making main method of class startup object?

in top app.xaml

exit="app_exit" startup="app_startup" 

in app.xaml.cs

void app_startup(object sender, startupeventargs e) private void app_exit(object sender, exiteventargs e) 

there other events can subscribe to, if needing override app startup need define in program.cs this:

public static class program     {          [stathread]         [permissionset(securityaction.demand, name = "fulltrust")]         public static void main(string[] args)         { 

and somewhere in there

app app = new app(); app.initializecomponent(); app.run(); 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -