protected override void OnStart(string[] args) { if (this.serviceThread != null) { throw new InvalidOperationException("Cannot start service twice in a row."); } // TODO: 865304 Used for functional tests only. Replace with a smarter appConfig-based solution string serviceName = args.FirstOrDefault(arg => arg.StartsWith(ServiceNameArgPrefix)); if (serviceName != null) { this.serviceName = serviceName.Substring(ServiceNameArgPrefix.Length); } this.serviceDataLocation = GVFSService.GetServiceDataRoot(this.serviceName); Directory.CreateDirectory(this.serviceDataLocation); this.tracer.AddLogFileEventListener( GVFSEnlistment.GetNewGVFSLogFileName(GVFSService.GetServiceLogsRoot(this.serviceName), GVFSConstants.LogFileTypes.Service), EventLevel.Verbose, Keywords.Any); try { this.Start(); } catch (Exception e) { this.LogExceptionAndExit(e, nameof(this.OnStart)); } }
public static void Main(string[] args) { GVFSPlatformLoader.Initialize(); AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; using (JsonTracer tracer = new JsonTracer(GVFSConstants.Service.ServiceName, GVFSConstants.Service.ServiceName)) { GVFSService service = new GVFSService(tracer); service.RunWithArgs(args); } }
public static void Main(string[] args) { AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; using (JsonEtwTracer tracer = new JsonEtwTracer(GVFSConstants.Service.ServiceName, GVFSConstants.Service.ServiceName)) { using (GVFSService service = new GVFSService(tracer)) { // This will fail with a popup from a command prompt. To install as a service, run: // %windir%\Microsoft.NET\Framework64\v4.0.30319\installutil GVFS.Service.exe ServiceBase.Run(service); } } }