Files
UA-.NETStandard/SampleApplications/Samples/NetCoreConsoleServer/Program.cs
T
Erich Barnstedt 738ae1545a Added Console Server sample project.
Added Sample project (needed for server).
Fixed copyright info.
Fixed all "easy" TODOs (or removed if not applicable anymore).
Removed HTTP transport settings (HTTP not supported anymore, only HTTPS).
Added option to load embedded resources from app directory as embedded resources not supported in .Net Standard.
2016-06-21 14:51:06 +02:00

42 lines
1.3 KiB
C#

using Opc.Ua;
using Opc.Ua.Configuration;
using Opc.Ua.Sample;
using System;
using System.Threading.Tasks;
namespace NetCoreConsoleServer
{
public class Program
{
public static void Main(string[] args)
{
try
{
ApplicationInstance application = new ApplicationInstance();
application.ApplicationName = "UA Sample Server";
application.ApplicationType = ApplicationType.Server;
application.ConfigSectionName = "Opc.Ua.SampleServer";
// load the application configuration.
Task<ApplicationConfiguration> task = application.LoadApplicationConfiguration(false);
task.Wait();
// check the application certificate.
Task<bool> task2 = application.CheckApplicationInstanceCertificate(false, 0);
task2.Wait();
// start the server.
Task task3 = application.Start(new SampleServer());
task3.Wait();
Console.WriteLine("Server Started. Press any key to exit...");
Console.ReadKey(true);
}
catch (Exception ex)
{
Console.WriteLine("Exit due to Exception: {0}", ex.Message);
}
}
}
}