Host in IIS - no client looging

Jul 3, 2008 at 10: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:
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IClogService" maxBufferSize="65536"
                    maxReceivedMessageSize="65536">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:4755/ClogService.svc" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_IClogService" contract="Orpius.Logging.ClientLogging.IClogService"
            name="BasicHttpBinding_IClogService" />
        </client>
    </system.serviceModel>
</configuration>

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

would very much appreciate your help
Thanks
Eran Shallev

Jul 3, 2008 at 12:33 PM
Daniel,

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.

Regards
Eran
Coordinator
Jul 9, 2008 at 6:50 AM
Eran,

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.

Cheers,
Daniel
Jul 10, 2008 at 9:26 AM
Daniel,

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

q:
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?

Thanks
Eran

 

Aug 25, 2008 at 6:38 PM
Edited Aug 25, 2008 at 8: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);

        }

Coordinator
Aug 26, 2008 at 1: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())
    {
        do
        {
            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;
            }
            else
            {
                if (reader.LocalName != "contract")
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format("ConfigUnrecognizedAttribute", reader.LocalName)));
                }
                base["contract"] = reader.Value;
            }
        }
        while (reader.MoveToNextAttribute());
    }
    reader.MoveToContent();
    if (reader.IsEmptyElement)
    {
        reader.Skip();
    }
    else
    {
        reader.ReadStartElement();
        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.

Cheers,
Daniel