Jump to content

Running .Net application by App()


Recommended Posts

I know how to run .Net executable by MainWindow() constructor but I have some resources defined in App.xaml and MainWindow() doesn't run without them. How to run application starting with App() constructor? Also I need to pass some parameters into MainWindow().

Link to comment

I assume you're talking about a WPF app.

WPF apps are normally launched via the static entry point App.Main() method, just like Windows Forms and Console apps (which by default specify a Main method in the arbitrarily named Program class).

The contents of this method is normally generated for you by the compiler, and typically creates an instance of the App class, calls it's InitializeComponent() method followed by the Run() method. The default implementation of the InitializeComponent() method is parse your App.xaml, determine the startup Window class (in your case, MainWindow.xaml) so that Run() method can startup the Dispatcher for the message loop  and load your window class.

Try calling the static Main() method in your assembly.

 

2020-08-07 12_11_31-Window.png

Link to comment
On 8/7/2020 at 6:30 PM, bartek618 said:

Thank you for response,

if I do it like this:
obraz.png.5591c8889f006576c22188aa4786b764.png

I get an error:
obraz.png.eb1ea022e35cef9d6d9f21e13ecf8f07.png

 

The method is static - you don't need a constructor node so try without that. 

The exception text isn't in a language I'm familiar with but I suspect it may be due to which thread is executing the clumps. Try also setting the VI execution properties for the enclosing VI to run in the UI thread only.

Link to comment
  • 2 weeks later...

I get an exception that Assembly.GetEntryAssembly() returns null. Vi execution is set to UI. Any idea what's going on?

 

Assembly.GetEntryAssembly() returns null. Set the Application.ResourceAssembly property or use the pack://application:,,,/assemblyname;component/
Edited by bartek618
Link to comment

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.