Esempio n. 1
0
        static void Main(string[] args)
        {
            const string SeCreateGlobalPrivilege = "SeCreateGlobalPrivilege";

            if (!OSEnvironmentHelper.IsVistaOrGreater)
            {
                try
                {
                    Utility.KeepOnlyPrivilegeInProcess(SeCreateGlobalPrivilege);
                }
                catch (Win32Exception exception)
                {
                    ListenerTraceUtility.EventLog.LogEvent(TraceEventType.Error,
                                                           (ushort)EventLogCategory.SharingService,
                                                           (uint)EventLogEventId.ServiceStartFailed,
                                                           false,
                                                           exception.ToString());

                    throw;
                }
            }

            // Hook up with unhandled exceptions.
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            List <ServiceBase> services = new List <ServiceBase>();

            netTcpPortSharing = new TcpPortSharing();
            services.Add(netTcpPortSharing);

            // We always add the services that share the same process to the service table so
            // that we don't have to stop the existing services when installing new services.
            // NOTE: Do not add code that really depends on WAS and MSMQ to the constructors
            // of these services.
            if (OSEnvironmentHelper.IsVistaOrGreater)
            {
                MainIis7(services);
            }
            ServiceBase.Run(services.ToArray());
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            const string SeCreateGlobalPrivilege = "SeCreateGlobalPrivilege";
            if (!OSEnvironmentHelper.IsVistaOrGreater)
            {
                try
                {
                    Utility.KeepOnlyPrivilegeInProcess(SeCreateGlobalPrivilege);
                }
                catch (Win32Exception exception)
                {
                    ListenerTraceUtility.EventLog.LogEvent(TraceEventType.Error,
                        (ushort)EventLogCategory.SharingService,
                        (uint)EventLogEventId.ServiceStartFailed,
                        false,
                        exception.ToString());

                    throw;
                }
            }

            // Hook up with unhandled exceptions.
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            List<ServiceBase> services = new List<ServiceBase>();
            netTcpPortSharing = new TcpPortSharing();
            services.Add(netTcpPortSharing);

            // We always add the services that share the same process to the service table so
            // that we don't have to stop the existing services when installing new services.
            // NOTE: Do not add code that really depends on WAS and MSMQ to the constructors
            // of these services.
            if (OSEnvironmentHelper.IsVistaOrGreater)
            {
                MainIis7(services);
            }
            ServiceBase.Run(services.ToArray());
        }