Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / SMSvcHost / System / ServiceModel / Activation / SMSvcHost.cs / 1 / SMSvcHost.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.Activation { using System; using System.IO; using System.ServiceProcess; using System.Security.Principal; using Microsoft.Win32; using System.Threading; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.ServiceModel.Activation.Diagnostics; using System.ServiceModel; using System.ComponentModel; static class SMSvcHost { static TcpPortSharing netTcpPortSharing; static TcpActivation netTcpActivator; static NamedPipeActivation netPipeActivator; static MsmqActivation netMsmqActivator; static string listenerAdapterNativeLibrary; internal static bool IsTcpPortSharingPaused { get { return netTcpPortSharing.IsPaused; } } internal static bool IsTcpActivationPaused { get { return netTcpActivator.IsPaused; } } internal static bool IsNamedPipeActivationPaused { get { return netPipeActivator.IsPaused; } } internal static bool IsWebhostSupported { get { bool isWebhostSupported = false; using (RegistryKey localMachine = Registry.LocalMachine) { using (RegistryKey versionKey = localMachine.OpenSubKey(@"Software\Microsoft\InetSTP")) { if (versionKey != null) { object majorVersion = versionKey.GetValue("MajorVersion"); if (majorVersion != null && majorVersion.GetType().Equals(typeof(int))) { if ((int)majorVersion >= 7) { isWebhostSupported = File.Exists(ListenerAdapterNativeLibrary); } } } } } return isWebhostSupported; } } internal static string ListenerAdapterNativeLibrary { get { if (listenerAdapterNativeLibrary == null) { listenerAdapterNativeLibrary = Environment.SystemDirectory + "\\inetsrv\\wbhstipm.dll"; } return listenerAdapterNativeLibrary; } } static void Main(string[] args) { const string SeCreateGlobalPrivilege = "SeCreateGlobalPrivilege"; if (!OSEnvironmentHelper.IsVistaOrGreater) { try { Utility.KeepOnlyPrivilegeInProcess(SeCreateGlobalPrivilege); } catch (Win32Exception exception) { ListenerTraceUtility.EventLog.LogEvent(TraceEventType.Error, System.ServiceModel.Diagnostics.EventLogCategory.SharingService, System.ServiceModel.Diagnostics.EventLogEventId.ServiceStartFailed, false, exception.ToString()); throw; } } // Hook up with unhandled exceptions. AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; Listservices = new List (); 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()); } static void MainIis7(List services) { netTcpActivator = new TcpActivation(); services.Add(netTcpActivator); netPipeActivator = new NamedPipeActivation(); services.Add(netPipeActivator); netMsmqActivator = new MsmqActivation(); services.Add(netMsmqActivator); } static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) { Exception exception = e.ExceptionObject as Exception; ListenerTraceUtility.EventLog.LogEvent(TraceEventType.Error, System.ServiceModel.Diagnostics.EventLogCategory.SharingService, System.ServiceModel.Diagnostics.EventLogEventId.SharingUnhandledException, false, exception == null ? string.Empty : exception.ToString()); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- SelectionItemProviderWrapper.cs
- RijndaelManagedTransform.cs
- PassportPrincipal.cs
- SelectionItemPattern.cs
- TimeSpanMinutesOrInfiniteConverter.cs
- MetadataArtifactLoaderCompositeResource.cs
- HyperLinkField.cs
- odbcmetadatacolumnnames.cs
- IDataContractSurrogate.cs
- HtmlInputReset.cs
- HostedNamedPipeTransportManager.cs
- DependencyObjectType.cs
- Currency.cs
- HostExecutionContextManager.cs
- FlowDocumentPage.cs
- InkPresenter.cs
- Vector3DCollection.cs
- ConnectionOrientedTransportBindingElement.cs
- SessionEndedEventArgs.cs
- ReadOnlyObservableCollection.cs
- InputElement.cs
- OleDbCommand.cs
- PenContext.cs
- XsdDataContractExporter.cs
- InvokeMethod.cs
- SignalGate.cs
- DocumentViewerConstants.cs
- TextOutput.cs
- EditableTreeList.cs
- ImageDrawing.cs
- Clipboard.cs
- DocumentViewerBaseAutomationPeer.cs
- CompModSwitches.cs
- RequestQueryParser.cs
- ReadWriteObjectLock.cs
- DesignColumnCollection.cs
- TileBrush.cs
- TaskScheduler.cs
- RelationshipConstraintValidator.cs
- HttpContextBase.cs
- RawStylusInputCustomData.cs
- AvTraceFormat.cs
- updatecommandorderer.cs
- ValueTypeFixupInfo.cs
- PointLight.cs
- SupportingTokenAuthenticatorSpecification.cs
- ListBoxItemAutomationPeer.cs
- BevelBitmapEffect.cs
- ConfigXmlWhitespace.cs
- MetadataCache.cs
- SecurityState.cs
- DefaultWorkflowSchedulerService.cs
- BinaryObjectWriter.cs
- SafeProcessHandle.cs
- MetadataUtil.cs
- DmlSqlGenerator.cs
- FrameworkElement.cs
- EmptyStringExpandableObjectConverter.cs
- PageAsyncTask.cs
- InstanceOwner.cs
- SettingsPropertyValueCollection.cs
- CompilerScopeManager.cs
- SystemUnicastIPAddressInformation.cs
- LineGeometry.cs
- Script.cs
- BoolExpressionVisitors.cs
- InertiaExpansionBehavior.cs
- ObjectDataProvider.cs
- Padding.cs
- HtmlEncodedRawTextWriter.cs
- CodeStatementCollection.cs
- ProjectionCamera.cs
- NativeMethodsOther.cs
- ResourcePermissionBase.cs
- PageTheme.cs
- ReflectTypeDescriptionProvider.cs
- SiteMapNode.cs
- DataControlExtensions.cs
- SafeHandles.cs
- Transform3DGroup.cs
- QilDataSource.cs
- ClickablePoint.cs
- FlowDocumentScrollViewerAutomationPeer.cs
- DataSourceComponent.cs
- XmlHierarchicalEnumerable.cs
- MissingSatelliteAssemblyException.cs
- ObjectDataSourceSelectingEventArgs.cs
- httpapplicationstate.cs
- DelegateSerializationHolder.cs
- FormViewInsertedEventArgs.cs
- LayoutInformation.cs
- DynamicRendererThreadManager.cs
- DefaultSerializationProviderAttribute.cs
- ProcessStartInfo.cs
- SmtpDigestAuthenticationModule.cs
- NamespaceCollection.cs
- TextCompositionEventArgs.cs
- DesigntimeLicenseContextSerializer.cs
- FtpRequestCacheValidator.cs
- DbMetaDataColumnNames.cs