protected override void InitializeRuntime()
        {
            ComPlusServiceHostTrace.Trace(TraceEventType.Information, TraceCode.ComIntegrationServiceHostStartingService,
                                          SR.TraceCodeComIntegrationServiceHostStartingService, this.info);
            try
            {
                DispatcherBuilder dispatcherBuilder = new DispatcherBuilder();
                dispatcherBuilder.InitializeServiceHost(this.Description, this);
            }
            catch (Exception e)
            {
                if (System.ServiceModel.DiagnosticUtility.ShouldTraceError)
                {
                    DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error,
                                                        (ushort)System.Runtime.Diagnostics.EventLogCategory.ComPlus,
                                                        (uint)System.Runtime.Diagnostics.EventLogEventId.ComPlusServiceHostStartingServiceError,
                                                        this.info.AppID.ToString(),
                                                        this.info.Clsid.ToString(),
                                                        e.ToString());
                }

                throw;
            }
            ComPlusServiceHostTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationServiceHostStartedServiceDetails,
                                          SR.TraceCodeComIntegrationServiceHostStartedServiceDetails, this.info, this.Description);
            ComPlusServiceHostTrace.Trace(TraceEventType.Information, TraceCode.ComIntegrationServiceHostStartedService,
                                          SR.TraceCodeComIntegrationServiceHostStartedService, this.info);
        }
 protected override void OnClose(TimeSpan timeout)
 {
     ComPlusServiceHostTrace.Trace(TraceEventType.Information, TraceCode.ComIntegrationServiceHostStoppingService,
                                   SR.TraceCodeComIntegrationServiceHostStoppingService, this.info);
     base.OnClose(timeout);
     ComPlusServiceHostTrace.Trace(TraceEventType.Information, TraceCode.ComIntegrationServiceHostStoppedService,
                                   SR.TraceCodeComIntegrationServiceHostStoppedService, this.info);
 }
 public System.ServiceModel.Description.ServiceDescription Load(ServiceHostBase host)
 {
     System.ServiceModel.Description.ServiceDescription service = new System.ServiceModel.Description.ServiceDescription(this.info.ServiceName);
     this.AddBehaviors(service);
     this.configLoader.LoadServiceDescription(host, service, this.info.ServiceElement, new Action <Uri>(host.LoadConfigurationSectionHelper));
     this.ValidateConfigInstanceSettings(service);
     ComPlusServiceHostTrace.Trace(TraceEventType.Information, 0x50005, "TraceCodeComIntegrationServiceHostCreatedServiceEndpoint", this.info, service.Endpoints);
     return(service);
 }
        public ContractDescription ResolveContract(string contractTypeString)
        {
            Guid iid;

            if (ServiceMetadataBehavior.MexContractName == contractTypeString)
            {
                iid = typeof(IMetadataExchange).GUID;
            }
            else
            {
                if (!DiagnosticUtility.Utility.TryCreateGuid(contractTypeString, out iid))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(SR.GetString(SR.ContractTypeNotAnIID, contractTypeString)));
                }

                ValidateInterface(iid);
            }

            // Check our cache to see if we already have one
            ContractDescription contract;

            if (this.contracts.TryGetValue(iid, out contract))
            {
                return(contract);
            }

            // If this is not IMetadataExchange continue
            if (iid != typeof(IMetadataExchange).GUID)
            {
                Type type;
                // Generate a managed type corresponding to the interface in question
                try
                {
                    this.interfaceResolver.FindOrCreateType(this.info.ServiceType, iid, out type, false, true);
                }
                catch (InvalidOperationException e)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(e.Message));
                }

                contract = CreateContractDescriptionInternal(iid, type);
            }
            else
            {
                contract = ResolveIMetadataExchangeToContract();
            }
            contracts.Add(iid, contract);

            ComPlusServiceHostTrace.Trace(TraceEventType.Verbose, TraceCode.ComIntegrationServiceHostCreatedServiceContract,
                                          SR.TraceCodeComIntegrationServiceHostCreatedServiceContract, this.info, contract);

            return(contract);
        }
Exemple #5
0
        public ServiceDescription Load(ServiceHostBase host)
        {
            ServiceDescription service = new ServiceDescription(this.info.ServiceName);

            // ServiceBehaviorAttribute needs to go first in the behaviors collection (before config stuff)
            AddBehaviors(service);

            this.configLoader.LoadServiceDescription(host, service, this.info.ServiceElement, host.LoadConfigurationSectionHelper);

            ValidateConfigInstanceSettings(service);

            ComPlusServiceHostTrace.Trace(TraceEventType.Information, TraceCode.ComIntegrationServiceHostCreatedServiceEndpoint,
                                          SR.TraceCodeComIntegrationServiceHostCreatedServiceEndpoint, this.info, service.Endpoints);

            return(service);
        }
 protected override void InitializeRuntime()
 {
     ComPlusServiceHostTrace.Trace(TraceEventType.Information, 0x50001, "TraceCodeComIntegrationServiceHostStartingService", this.info);
     try
     {
         new DispatcherBuilder().InitializeServiceHost(base.Description, this);
     }
     catch (Exception exception)
     {
         if (DiagnosticUtility.ShouldTraceError)
         {
             DiagnosticUtility.EventLog.LogEvent(TraceEventType.Error, EventLogCategory.ComPlus, (EventLogEventId)(-1073610730), new string[] { this.info.AppID.ToString(), this.info.Clsid.ToString(), exception.ToString() });
         }
         throw;
     }
     ComPlusServiceHostTrace.Trace(TraceEventType.Verbose, 0x50004, "TraceCodeComIntegrationServiceHostStartedServiceDetails", this.info, base.Description);
     ComPlusServiceHostTrace.Trace(TraceEventType.Information, 0x50002, "TraceCodeComIntegrationServiceHostStartedService", this.info);
 }
Exemple #7
0
        public ContractDescription ResolveContract(string contractTypeString)
        {
            Guid gUID;
            ContractDescription description;

            if ("IMetadataExchange" == contractTypeString)
            {
                gUID = typeof(IMetadataExchange).GUID;
            }
            else
            {
                if (!System.ServiceModel.DiagnosticUtility.Utility.TryCreateGuid(contractTypeString, out gUID))
                {
                    throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("ContractTypeNotAnIID", new object[] { contractTypeString })));
                }
                this.ValidateInterface(gUID);
            }
            if (!this.contracts.TryGetValue(gUID, out description))
            {
                if (gUID != typeof(IMetadataExchange).GUID)
                {
                    Type type;
                    try
                    {
                        this.interfaceResolver.FindOrCreateType(this.info.ServiceType, gUID, out type, false, true);
                    }
                    catch (InvalidOperationException exception)
                    {
                        throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(exception.Message));
                    }
                    description = this.CreateContractDescriptionInternal(gUID, type);
                }
                else
                {
                    description = this.ResolveIMetadataExchangeToContract();
                }
                this.contracts.Add(gUID, description);
                ComPlusServiceHostTrace.Trace(TraceEventType.Verbose, 0x50003, "TraceCodeComIntegrationServiceHostCreatedServiceContract", this.info, description);
            }
            return(description);
        }