Dispatcher BeginInvoke Syntax

The problem is that the compiler doesn’t know what kind of delegate you’re trying to convert the lambda expression to. You can fix that either with a cast, or a separate variable: private void OnSaveCompleted(IAsyncResult result) { Dispatcher.BeginInvoke((Action) (() => { context.EndSaveChanges(result); })); } or private void OnSaveCompleted(IAsyncResult result) { Action action = () => … Read more

How to handle Ajax JQUERY POST request with WCF self-host

Ok, now there are some real MSDN gurus out there who have written solutions, but I cannot figure them out: http://blogs.msdn.com/b/carlosfigueira/archive/2012/05/15/implementing-cors-support-in-wcf.aspx But I have come up with a simple solution. At least in WCF 4.5 you can add your own OperationContract for dealing with OPTIONS requests: [OperationContract] [WebInvoke(Method = “OPTIONS”, UriTemplate = “*”)] void GetOptions(); … Read more

Turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server

Define a behavior in your .config file: <configuration> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name=”debug”> <serviceDebug includeExceptionDetailInFaults=”true” /> </behavior> </serviceBehaviors> </behaviors> … </system.serviceModel> </configuration> Then apply the behavior to your service along these lines: <configuration> <system.serviceModel> … <services> <service name=”MyServiceName” behaviorConfiguration=”debug” /> </services> </system.serviceModel> </configuration> You can also set it programmatically. See this question.