Default Binding Fails On Second Try


I found the following code that allows us to get a default binding.
var result = new ClogServiceClient(new ClogBasicHttpBinding(), new EndpointAddress(new Uri(HtmlPage.Document.DocumentUri, "ClogService.svc")));
Altough it works fine when we try to get the configuration, the second time, when it writes to the log, it does it from a Service Callback (another thread) and it fails because the HtmlPage.Document can only be accessed from the UI Thread.
Closed Dec 2, 2009 at 3:55 PM by DanielVaughan
Patch applied to source located at http://calcium.codeplex.com/SourceControl/ListDownloadableCommits.aspx


DanielVaughan wrote Oct 12, 2009 at 3:38 PM

For now please use a customized ServiceReference.ClientConfig.

wrote Oct 13, 2009 at 2:09 AM

mamadero wrote Oct 13, 2009 at 2:09 AM

That's my current workaround.


mamadero wrote Nov 18, 2009 at 4:38 AM


Is there any update about this?
I'm trying to use this library on a different project and in this case I can't afford to use a different ClientConfig, since we have a lot of different deployment environements that are currently inferred based on the host where the app was downloaded from.
What I'm doing is that I'm caching the Endpoint the first time and just use it on subsequence calls. I will be happy to submit a patch, but I don't want to branch the project :(


DanielVaughan wrote Nov 18, 2009 at 8:13 AM

If you have a patch then please submit it. I would be more than happy to integrate it.

In the future, once I release the Silverlight version of Calcium, I will be including the latest source for Clog in the Calcium repository. This is because of the shared VS projects.


mamadero wrote Nov 18, 2009 at 11:13 AM

That's great.

It's a simple change. I just added a field for the endpoint and I use that on following attempts. The first one is done on the UI Thread and followings don't have to access the HtmlPage object, thus avoiding the Cross Thread Exception. This is the whole GetClogService method. The change is at the end.

private static EndpointAddress fallBackEndpoint;
    IClogService GetClogService()
        if (!clogServiceConfigFailed)
                var clogService = ChannelManagerSingleton.Instance.GetChannel<IClogService>();
                return clogService;
            catch (Exception ex)
                clogServiceConfigFailed = true;
                    new InternalMessageEventArgs(
                        "Unable to use WCF config for channel. Using default configuration. This may be acceptable if no end point has been defined.",
            //              catch
            //              {
            //                  clogServiceConfigFailed = true;
            //              }

        if (fallBackEndpoint == null)
            fallBackEndpoint = new EndpointAddress(new Uri(HtmlPage.Document.DocumentUri, "ClogService.svc"));
        var result = new ClogServiceClient(new ClogBasicHttpBinding(),fallBackEndpoint);

        return result;

On another topic. What is Calcium?

DanielVaughan wrote Nov 18, 2009 at 12:28 PM

Thanks Miguel.

Info on Calcium can be found at http://www.calciumsdk.net/


mamadero wrote Nov 18, 2009 at 11:29 PM


Thanks. I took a quick look at Calcium, it looks good. I think there're many gaps to close from where P&P left it.

wrote Dec 2, 2009 at 3:55 PM

wrote Feb 14, 2013 at 1:06 AM

wrote May 16, 2013 at 6:02 AM