Code:
/ WCF / WCF / 3.5.30729.1 / untmp / Orcas / SP / ndp / cdf / src / WCF / ServiceModel / System / ServiceModel / ComIntegration / WebHostedComPlusServiceHost.cs / 2 / WebHostedComPlusServiceHost.cs
//------------------------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. //----------------------------------------------------------------------------- namespace System.ServiceModel.ComIntegration { using System; using System.Collections.Generic; using System.Runtime.InteropServices; using System.ServiceModel; using System.ServiceModel.Configuration; using System.ServiceModel.Diagnostics; class WebHostedComPlusServiceHost : ComPlusServiceHost { public WebHostedComPlusServiceHost (string webhostParams, Uri[] baseAddresses) { foreach (Uri address in baseAddresses) this.InternalBaseAddresses.Add(address); // Split up the parameter string into "clsid,appid". // string[] parameters = webhostParams.Split(','); if (parameters.Length != 2) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.ListenerInitFailed( SR.GetString(SR.ServiceStringFormatError, webhostParams))); } Guid clsid; Guid appId; if ( !DiagnosticUtility.Utility.TryCreateGuid(parameters[0], out clsid)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.ListenerInitFailed( SR.GetString(SR.ServiceStringFormatError, webhostParams))); } if ( !DiagnosticUtility.Utility.TryCreateGuid(parameters[1], out appId)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.ListenerInitFailed( SR.GetString(SR.ServiceStringFormatError, webhostParams))); } // "B" == "With dashes and curly braces" // (The catalog gives us GUIDs in this format) // string clsidString = clsid.ToString("B").ToUpperInvariant (); // Look up the COM+ AdminSDK information for this // AppID/CLSID pair. // ComCatalogObject application; application = CatalogUtil.FindApplication(appId); if (application == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.ListenerInitFailed( SR.GetString(SR.ApplicationNotFound, appId.ToString("B").ToUpperInvariant ()))); } ComCatalogCollection classes; classes = application.GetCollection("Components"); ComCatalogObject classObject = null; foreach(ComCatalogObject tempClassObject in classes) { string otherClsid = (string)tempClassObject.GetValue("CLSID"); if (clsidString.Equals( otherClsid, StringComparison.OrdinalIgnoreCase)) { classObject = tempClassObject; break; } } if (classObject == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.ListenerInitFailed( SR.GetString(SR.ClsidNotInApplication, clsidString, appId.ToString("B").ToUpperInvariant()))); } // Load up Indigo configuration, get the configuration for // this service. // ServicesSection services = ServicesSection.GetSection(); ServiceElement service = null; foreach (ServiceElement serviceInConfig in services.Services) { Guid clsidFromConfig = Guid.Empty; Guid appidFromConfig = Guid.Empty; string[] serviceParams = serviceInConfig.Name.Split(','); if (serviceParams.Length != 2) { continue; } if ( !DiagnosticUtility.Utility.TryCreateGuid(serviceParams[0], out appidFromConfig)) { // We are tolerant of having non COM+ based services // for webhost. continue; } if ( !DiagnosticUtility.Utility.TryCreateGuid(serviceParams[1], out clsidFromConfig)) { // We are tolerant of having non COM+ based services // for webhost. continue; } if (clsidFromConfig == clsid && appidFromConfig == appId) { service = serviceInConfig; break; } } if (service == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(System.ServiceModel.ComIntegration.Error.ListenerInitFailed( SR.GetString(SR.ClsidNotInConfiguration, clsidString))); } // Hosting mode evaluation // HostingMode hostingMode; int activation = (int)application.GetValue("Activation"); if (activation == 0) { hostingMode = HostingMode.WebHostInProcess; } else { hostingMode = HostingMode.WebHostOutOfProcess; } // Now we have everything we need, do common // initialization. // Initialize (clsid, service, application, classObject, hostingMode); } } } // 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
- ReaderWriterLockWrapper.cs
- CommonDialog.cs
- TypeBuilderInstantiation.cs
- HostnameComparisonMode.cs
- SmtpAuthenticationManager.cs
- SessionEndingCancelEventArgs.cs
- SqlBuilder.cs
- AssemblyResourceLoader.cs
- SqlProvider.cs
- OracleParameter.cs
- ExceptionValidationRule.cs
- SoapObjectReader.cs
- OutputCacheProviderCollection.cs
- ThrowHelper.cs
- NetStream.cs
- WindowAutomationPeer.cs
- ActivationArguments.cs
- FragmentQueryProcessor.cs
- ServiceHttpModule.cs
- SimpleBitVector32.cs
- UICuesEvent.cs
- XmlnsDefinitionAttribute.cs
- InertiaRotationBehavior.cs
- WindowsIPAddress.cs
- OnOperation.cs
- BuildProviderAppliesToAttribute.cs
- SettingsPropertyIsReadOnlyException.cs
- TextBox.cs
- OleDbRowUpdatedEvent.cs
- DeploymentSection.cs
- SqlMultiplexer.cs
- RemoteAsymmetricSignatureFormatter.cs
- RequestResizeEvent.cs
- SecurityContext.cs
- Predicate.cs
- GenericTypeParameterBuilder.cs
- DesignerDataTable.cs
- CustomLineCap.cs
- TextRange.cs
- BamlLocalizer.cs
- RegexStringValidatorAttribute.cs
- ElementNotEnabledException.cs
- Span.cs
- AccessDataSource.cs
- Mutex.cs
- UInt32.cs
- SimpleTextLine.cs
- OleDbWrapper.cs
- _NetRes.cs
- EmbossBitmapEffect.cs
- SizeFConverter.cs
- OrderToken.cs
- TraceSection.cs
- HighlightVisual.cs
- DataGridHeaderBorder.cs
- StrongTypingException.cs
- PageTheme.cs
- TemplateNameScope.cs
- CryptoStream.cs
- GridErrorDlg.cs
- HwndSubclass.cs
- StaticExtensionConverter.cs
- _ReceiveMessageOverlappedAsyncResult.cs
- SqlClientWrapperSmiStream.cs
- WebPartTransformerAttribute.cs
- RootBrowserWindow.cs
- XmlSequenceWriter.cs
- WindowsRichEditRange.cs
- UTF7Encoding.cs
- WindowsSolidBrush.cs
- ConfigXmlElement.cs
- SimpleParser.cs
- _WinHttpWebProxyDataBuilder.cs
- TextViewBase.cs
- JsonEncodingStreamWrapper.cs
- SecurityRuntime.cs
- WebPartCancelEventArgs.cs
- DateTimeSerializationSection.cs
- IISUnsafeMethods.cs
- EntryPointNotFoundException.cs
- MetadataFile.cs
- UriScheme.cs
- SoundPlayer.cs
- RequiredFieldValidator.cs
- WebPartChrome.cs
- ContentPresenter.cs
- SqlTrackingService.cs
- BinaryObjectInfo.cs
- DebuggerAttributes.cs
- FreeFormDesigner.cs
- GridViewDeleteEventArgs.cs
- Compiler.cs
- Table.cs
- Pkcs9Attribute.cs
- CqlIdentifiers.cs
- ViewStateModeByIdAttribute.cs
- SessionEndingCancelEventArgs.cs
- WebPartEditorOkVerb.cs
- Track.cs
- HtmlContainerControl.cs