Creating and configurating an endpoint for remote logging service with Silverlight

Topics: Logging Application Block, Silverlight Integration Pack
Nov 14, 2011 at 10:58 AM


i want to create an endpoint programmatically for the remote logging service WITHOUT use un ServiceReferente.ClientConfig in the Silverlight Project.

Are there any way for do it???

Thanks a lot.

Nov 15, 2011 at 11:11 AM

Yes, you can configure the Silverlight client programmatically.

The block is currently set up to use the configuration so you will need to create an implementation of ILoggingServiceFactory and then configure Enterprise Library to use it.


    public class MyLoggingServiceFactory : ILoggingServiceFactory, IDisposable
        private ChannelFactory<ILoggingService> channelFactory;

        public MyLoggingServiceFactory(string endpointUrl)
            HttpTransportBindingElement httpTransport = new HttpTransportBindingElement
                MaxBufferSize = int.MaxValue,
                MaxReceivedMessageSize = int.MaxValue

            BinaryMessageEncodingBindingElement messageEncoding = new BinaryMessageEncodingBindingElement
                MessageVersion = MessageVersion.Default

            CustomBinding binding = new CustomBinding(messageEncoding, httpTransport);

            this.channelFactory = new ChannelFactory<ILoggingService>(binding, new EndpointAddress(endpointUrl));

        public virtual ILoggingService CreateChannel()
            if (this.channelFactory == null)
                throw new InvalidOperationException("LoggingServiceFactory_EndpointConfigurationNameNotSet");

            return new LoggingServiceProxy(this.channelFactory);

        public void Dispose()

        protected virtual void Dispose(bool disposing)
            if (disposing)
                using (this.channelFactory) { this.channelFactory = null; }


And then at startup configure Enterprise Library to use the new factory:

var configBuilder = new ConfigurationSourceBuilder();
        .WithLoggingServiceFactory(new MyLoggingServiceFactory("http://localhost:51625/LogService.svc"))
var configSource = new DictionaryConfigurationSource();
EnterpriseLibraryContainer.Current = EnterpriseLibraryContainer.CreateDefaultContainer(configSource);


Randy Levy
Enterprise Library support engineer