Clog default binding

Jun 4, 2009 at 2:38 PM

Hi Daniel,

my app needed the default binding feature of Clog, unfortunatly it was not working properly. I'm using SL3 Beta 1 and was getting this exception when trying to log stuff :

System.InvalidOperationException: This operation can only occur on the UI Thread.
   at System.Windows.Hosting.NativeHost.VerifyThread()
   at System.Windows.Browser.HtmlPage.VerifyThread()
   at System.Windows.Browser.HtmlPage.VerifyThreadAndEnabled()
   at System.Windows.Browser.HtmlPage.get_Document()
   at DanielVaughan.Logging.Log.GetClogService()
   at DanielVaughan.Logging.Log.WriteLogEntryAux(LogEntryData entry, ClientConfigurationData config)

What was really weird was that calling the GetConfiguration method was working fine but not the call to WriteEntrySilverlight.
I decided to try obtain a reference to IClogService (even the default one) through the ChannelManagerSingleton. Now it works fine.

Here is what I did in DanielVaughan.ChannelManagerSingleton (beginning line 77) :
     /* We don't cache the factory as it contains a list of channels 
    * that aren't removed if a fault occurs. */
                    ChannelFactory<TChannel> channelFactory;
                    System.ServiceModel.Channels.Binding b = new BasicHttpBinding();
                    Uri uri = new Uri(HtmlPage.Document.DocumentUri, "ClogService.svc");

                        channelFactory = new ChannelFactory<TChannel>("*");
                    catch (Exception ex)
                        channelFactory = new ChannelFactory<TChannel>(b, new EndpointAddress(uri));                        

It's quick and dirty !

Can you explain what's going with your method not working with SL 3 (cause I'm sure you've tested it successfully with SL 2) ?


Jun 4, 2009 at 9:18 PM

Hi Jeff,

Thanks for your message.

I haven't done any testing with SL3 due to other open-source commitments, and I'm itching to make some improvements to Clog for SL3 RTM.

So, thanks for raising this. I'm sorry I can't give you a better explanation right now.

Cheers, Daniel