.NET MAUI How to receive process parameters

Copper Contributor

Hello everyone :

             When I was researching .NET MAUI, I didn't find an object that can receive process parameters, does anyone know?

 

 

namespace AutoUpdate.WpfNet6_Sample
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            var args = e.Args;
            base.OnStartup(e);
        }
    }
}

 

 

For example, in wpf, you can get the parameters passed by the process through the args of Onstartup. How to get it in MAUI?

 

like this?

 

    protected override Window CreateWindow(IActivationState activationState)
    {
#if WINDOWS
		var state = activationState as ActivationState;
		var args1 = state.LaunchActivatedEventArgs;
		//var args =  Environment.GetCommandLineArgs();
		return new Window(new MainPage(args1.Arguments));
#endif
		return null;
	}

 

 

0 Replies