예제 #1
0
        protected override void OnStart(string[] args)
        {
            try
            {
                if (DiagnosticUtility.ShouldTraceInformation)
                {
                    ListenerTraceUtility.TraceEvent(TraceEventType.Information, ListenerTraceCode.ServiceStart, SR.GetString(SR.TraceCodeServiceStart), this);
                }

                ListenerConfig.EnsureInitializedForNetTcp();

#if DEBUG
                if (DebuggableService.DelayStart(ServiceName))
                {
                    (new Thread(new ThreadStart(Start))).Start();
                    return;
                }
#endif
                Start();
            }
            catch (Exception exception)
            {
                // Log the error to eventlog.
                ListenerTraceUtility.EventLog.LogEvent(TraceEventType.Error,
                                                       (ushort)EventLogCategory.SharingService,
                                                       (uint)EventLogEventId.ServiceStartFailed,
                                                       false,
                                                       exception.ToString());

                throw;
            }
        }
예제 #2
0
        void GrantPermissionToAllowedAccounts()
        {
            // SECURITY
            // we need to do this to allow services to lookup our LogonSid and ProcessToken User
            lock (ThisLock)
            {
                Utility.AddRightGrantedToAccounts(ListenerConfig.GetAllowAccounts(this.transportType),
                                                  ListenerUnsafeNativeMethods.PROCESS_QUERY_INFORMATION, true);

                Utility.AddRightGrantedToAccounts(ListenerConfig.GetAllowAccounts(this.transportType),
                                                  ListenerUnsafeNativeMethods.TOKEN_QUERY, false);
            }
        }
예제 #3
0
        static Binding CreateRegisterBinding(TransportType transportType)
        {
            NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);

            binding.MaxReceivedMessageSize = ListenerConstants.RegistrationMaxReceivedMessageSize;
            CustomBinding customBinding = new CustomBinding(binding);
            NamedPipeTransportBindingElement namedPipeBindingElement = customBinding.Elements.Find <NamedPipeTransportBindingElement>();

            namedPipeBindingElement.ExposeConnectionProperty = true;
            namedPipeBindingElement.AllowedUsers             = ListenerConfig.GetAllowAccounts(transportType);
            customBinding.ReceiveTimeout = TimeSpan.MaxValue;
            return(customBinding);
        }
예제 #4
0
        void CreateSharedMemory()
        {
            try
            {
                sharedMemory = SharedMemory.Create(ListenerConstants.GlobalPrefix + sharedMemoryName, controlServiceGuid,
                                                   ListenerConfig.GetAllowAccounts(this.transportType));

                Debug.Print("SharedMemory.Create() sharedMemoryName: " + sharedMemoryName);
            }
            catch (Win32Exception exception)
            {
                Debug.Print("SharedMemory.Create() exception: " + exception);
                DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                    (ushort)EventLogCategory.SharingService,
                                                    (uint)EventLogEventId.StartErrorPublish,
                                                    exception.ToString());

                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(SR.GetString(SR.ServiceStartErrorPublish, this.serviceName),
                                                        exception));
            }
        }
        protected override void OnStart(string[] args)
        {
            try
            {
                ListenerConfig.EnsureInitializedForNetPipe();

                base.OnStart(args);
                // we don't support delay starting the sharing piece for named pipes
                serviceCore.Start();
            }
            catch (Exception exception)
            {
                // Log the error to eventlog.
                ListenerTraceUtility.EventLog.LogEvent(TraceEventType.Error,
                                                       (ushort)System.Runtime.Diagnostics.EventLogCategory.ListenerAdapter,
                                                       (uint)System.Runtime.Diagnostics.EventLogEventId.ServiceStartFailed,
                                                       false,
                                                       exception.ToString());

                throw;
            }
        }