protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
ApplicationInstance application = new ApplicationInstance();
application.ApplicationName = "UA Sample Client";
application.ApplicationType = ApplicationType.ClientAndServer;
application.ConfigSectionName = "Opc.Ua.SampleClient";
// helper to let Opc.Ua Utils find the localFolder in the environment
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
Utils.DefaultLocalFolder = localFolder.Path;
// set empty page for MessageDlg
Window.Current.Content = new ClientPage();
// Ensure the current window is active
Window.Current.Activate();
// Allow the current window to activate since the stack initialization below can take some time
// and the app can be terminated by the runtime if this takes too long
await Task.Delay(1);
try
{
// load the application configuration.
await application.LoadApplicationConfiguration(false);
// check the application certificate.
await application.CheckApplicationInstanceCertificate(false, 0);
// run the application interactively.
Window.Current.Content = new ClientPage(application.ApplicationConfiguration.CreateMessageContext(), application, null, application.ApplicationConfiguration);
// start the server.
await application.Start(new SampleServer());
}
catch (Exception ex)
{
Utils.Trace("Exception:" + ex.Message);
MessageDlg dialog = new MessageDlg(ex.Message);
await dialog.ShowAsync();
Application.Current.Exit();
}
}