Host in IIS - no client looging

Jul 3, 2008 at 11:26 AM
Daniel hi,

I published my Clog based Silverlight application into IIS.
Client Logging, which worked fine when run in Visual Studio, now fails.

the ServiceReferences.ClientConfig reads:
                <binding name="BasicHttpBinding_IClogService" maxBufferSize="65536"
                    <security mode="None" />
            <endpoint address="http://localhost:4755/ClogService.svc" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IClogService" contract="Orpius.Logging.ClientLogging.IClogService"
            name="BasicHttpBinding_IClogService" />

I tried working on the <endpoint address> configuration, but did not get it right yet.

would very much appreciate your help
Eran Shallev

Jul 3, 2008 at 1:33 PM

I should add to the first post:
when the Client app attempts to log, i.e. Orpius.Loggimg.Silverlight attempts to call the ClogService, an exception is thrown:

"Unhandled Error in Silverlight 2 Application Exception has been thrown by the target of an invocation.  
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)\n  
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)\n  
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)\n  
at System.Delegate.DynamicInvokeImpl(Object[] args)\n  
at System.Delegate.DynamicInvoke(Object[] args)\n  
at System.Windows.Threading.DispatcherOperation.Invoke()"

maybe that gives some insight.

Jul 9, 2008 at 7:50 AM

Are you using IIS 7 on Vista by any chance? If you are and you are using the default (IPv4) ranges specified in the example web.config, then the filter will prevent logging. In any case, comment out the filters for troubleshooting.
I’ve released a new version, which I have tested on IIS 7 on Vista. The only change required when publishing is to modify the ServiceReferences.ClientConfig file in the ExampleSilverlightProject project to match your deployment url.

Sorry for the delay in responding.

Jul 10, 2008 at 10:26 AM

The 1_1_5 release works fine (checked on XP, IIS6).

ServiceReferences.ClientConfig is part of .xap file.
my concern is how to modify the endpoint address after deploy (on production).
We managed to do that by setting the address in the Web.config file - which overides the configuration in the ServiceReferences.ClientConfig:


endpoint address="http://localhost/clog/ClogService.svc" binding="basicHttpBinding" contract="Orpius.Logging.IClogService">

is that the approach you recommend?



Aug 25, 2008 at 7:38 PM
Edited Aug 25, 2008 at 9:53 PM
I couldn’t make it work with the web.config change that eranshalley mentions. And because we have several developers working on the same silverlight project, each with its local server, a test server and a production server, we need a way to make the service work, regardless of the server and without touching the ServiceReferences.ClientConfig file.

So we modified the Log class on the SilverlightLogging project to store an EndpointAddress object that points to the page point of origin.

But I would be better if there was a way to define at least the endpoint address from the App, when the silverlight program is starting. The LogManager could store it, since already has a couple of static variables.

On the Log constructor we called a method that creates the parameters for the ClogServiceClient:

            binding = new System.ServiceModel.BasicHttpBinding();

            binding.MaxBufferSize = 2147483647;

            binding.MaxReceivedMessageSize = 2147483647;

            address = new System.ServiceModel.EndpointAddress(new Uri(Application.Current.Host.Source, "../../ClogService.svc")); //assumes that the service is on root.

And we modified the CreateServiceClient method:

        ClogServiceClient CreateServiceClient()


                                   return new ClogServiceClient(binding, address);


Aug 26, 2008 at 2:26 AM
The manner in which the endpoint address is constructed from the client config is hardwired for an absolute address, as the following reflector excerpt the internal class ChannelEndpointElement shows:

public void ReadXml(XmlReader reader)
    if (reader.MoveToFirstAttribute())
            if (reader.LocalName == "name")
                base["name"] = reader.Value;
            else if (reader.LocalName == "address")
                base["address"] = new Uri(reader.Value, UriKind.Absolute); /* Must be absolute. */
            else if (reader.LocalName == "binding")
                base["binding"] = reader.Value;
            else if (reader.LocalName == "bindingConfiguration")
                base["bindingConfiguration"] = reader.Value;
                if (reader.LocalName != "contract")
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format("ConfigUnrecognizedAttribute", reader.LocalName)));
                base["contract"] = reader.Value;
        while (reader.MoveToNextAttribute());
    if (reader.IsEmptyElement)
        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format("ConfigUnrecognizedElement", reader.LocalName)));

So, until this changes we won’t be able to use a relative address when using the ServiceReferences config file for Clog’s configuration.

Your approach seems reasonable for your scenario. One other might be to have a ‘linked’ ServiceReferences.ClientConfig file in your solution, whereby each dev can customize the file. Yet another might be to use a Clog specific config file and perform the configuration of the proxy manually.

Hardwiring Clog to a current page relative address may not suit everybody because Clog may be used to log to a centralised server on a different domain.