Ejemplo n.º 1
0
        void AddHostedTransportConfigurationIis7(string protocol)
        {
            HostedTransportConfiguration configuration = null;

            try
            {
                ServiceHostingEnvironmentSection section = ServiceHostingEnvironmentSection.GetSection();
                if (section.TransportConfigurationTypes.ContainsKey(protocol))
                {
                    TransportConfigurationTypeElement element = section.TransportConfigurationTypes[protocol];
                    Debug.Print("HostedTransportConfigurationManager.AddHostedTransportConfigurationIis7() found TransportConfigurationTypes for protocol: " + protocol + " name: " + element.TransportConfigurationType);

                    Type type = Type.GetType(element.TransportConfigurationType);
                    configuration = Activator.CreateInstance(type) as HostedTransportConfiguration;
                    configurations.Add(protocol, configuration);
                }
                else
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR.Hosting_ProtocolNoConfiguration(protocol)));
                }
            }
            catch (Exception exception)
            {
                if (!Fx.IsFatal(exception))
                {
                    Debug.Print("HostedTransportConfigurationManager.AddHostedTransportConfigurationIis7() caught exception: " + exception);
                    if (DiagnosticUtility.ShouldTraceError)
                    {
                        TraceUtility.TraceEvent(TraceEventType.Error, TraceCode.WebHostProtocolMisconfigured, SR.TraceCodeWebHostProtocolMisconfigured,
                                                new StringTraceRecord("Protocol", protocol),
                                                this, exception);
                    }
                }
                throw;
            }
        }
Ejemplo n.º 2
0
        private void AddHostedTransportConfigurationIis7(string protocol)
        {
            HostedTransportConfiguration configuration = null;

            try
            {
                ServiceHostingEnvironmentSection section = ServiceHostingEnvironmentSection.GetSection();
                if (!section.TransportConfigurationTypes.ContainsKey(protocol))
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activation.SR.Hosting_ProtocolNoConfiguration(protocol)));
                }
                TransportConfigurationTypeElement element = section.TransportConfigurationTypes[protocol];
                configuration = Activator.CreateInstance(Type.GetType(element.TransportConfigurationType)) as HostedTransportConfiguration;
                this.configurations.Add(protocol, configuration);
            }
            catch (Exception exception)
            {
                if (!Fx.IsFatal(exception) && DiagnosticUtility.ShouldTraceError)
                {
                    System.ServiceModel.Activation.Diagnostics.TraceUtility.TraceEvent(TraceEventType.Error, 0x90006, System.ServiceModel.Activation.SR.TraceCodeWebHostProtocolMisconfigured, new StringTraceRecord("Protocol", protocol), this, exception);
                }
                throw;
            }
        }