Tag Archives: WCF

WCF Tips

http://stackoverflow.com/questions/1408509/sometimes-adding-a-wcf-service-reference-generates-an-empty-reference-cs

Generally I find that it’s a codegen issue and most of the time it’s because I’ve got a type name conflict it couldn’t resolve.

If you right-click on your service reference and click configure and uncheck “Reuse Types in Referenced Assemblies” it’ll likely resolve the issue.

What I found was that enums must be tagged with [EnumMember] attribute for the auto-generation to work

http://stackoverflow.com/questions/6206160/wcf-client-freezes-when-calling-method-from-service

[CallbackBehavior(UseSynchronizationContext=false)]

WCF behaves differently when hosted in UI thread. In such scenario all request are processed in sequential order in standard windows message loop so if you call the service you blocked your current thread but the service calls back your client and it waits to process the message but it can’t because thread is blocked by the initial call = deadlock until initial request timenouts. By using last mentioned behavior you will say WCF to not join windows message loop and instead process messages in separate threads as usual. There is no security issue with this except the fact that you cannot access UI control from methods running in other threads – both WinForms and WPF has approaches to pass commands from other thread.

Advertisements