WCF – Message Exchange Patterns (MEPs)

Message Exchange Pattern describes how the client and server should exchange messages, and also the MEP will make clear that the client is going to wait for any response from the service or just simply sending is enough ,or the client is expecting any callbacks from the service.

WCF supports three Message Exchange Patterns (MEPs). They are as follows.

Request-Reply

One-Way

WCF One-Way Message Exchange Pattern

Duplex

The below given diagram show how Duplex (One-Way) works.

Below given diagram shows how a Duplex (Request-Reply) MEP works,

Read more from CodeProject.com

 

WCF-Global Exception Handling using IErrorHandler

Global Exception Handling – IServiceBehavior and IErrorHandler
To demonstrate this we need to create an ErrorHandler class by implementing the IErrorHandler and also a ServiceBehaviorAttribute class by impementing a IServiceBehavior. IServiceBehavior allows you to implement a service behaviour attribute which takes a custom error handler parameter which implements IErrorHandler

The IErrorHandler type exposes two methods. HandleError and ProvideFault.

  • Use the HandleError method to implement error-related behaviors such as error logging, system notifications, shutting down the application, and so on, and return a value that specifies whether the exception has been handled appropriate.
  • ProvideFault enables the creation of a custom FaultException<TDetail> that is returned to to the client from an exception in the course of a service method.

The IServiceBehavior type exposes three methods. AddBindingParameters, ApplyDispatchBehavior and Validate. For this article we are much interested only in ApplyDispatchBehavior method.

  • Here AddBindingParameters provides the ability to pass custom data to binding elements to support the contract implementation.
  • ApplyDispatchBehavior provides the ability to change run-time property values or insert custom extension objects such as error handlers, message or parameter interceptors, security extensions, and other custom extension objects.
  • Use the Validate method to confirm whether the current service can execute properly according to your scenario.

How it works

Whenever an unhandled exception occurs in a service decorated with the service behaviour attribute, two methods on the global error handler are called automatically: ProvideFault which allows you to construct a FaultException (rather than let ServiceModel do it), and HandleError which is intended for logging. The ProvideFault method is called first on the worker thread that is invoking the service call and HandlerError is called asynchronously on a separate thread, so lengthy logging operations don’t block the service request thread from sending a FaultException back to the client immediately.

WCF Global Exception Handling

Read more from CodeProject.com

WCF – Exception Handling, FaultException,FaultException and FaultContracts

Whenever we write a program we should expect the unexpected and add appropriate code to handle those exceptions.When we write a windows based application we use try/catch blocks in our methods to catch exceptions, and also we show a user friendly message in UI.

But when we work with WCF Service, It is not that much straight forward, So

  • How do we handle exceptions in WCF Service?
  • How to propagate a user-friendly error message to the client, who consumes the WCF Service?
  • How to send business rule validation messages to WCF client?

Handling exceptions in WCF Service is different than usual exceptions in .NET. As the WCF clients may not be based on .NET Technologies we cannot utilize the .NET Exception object to exchange exception details over the wire. For this purpose we should have a generic way to pass exception details to all type of clients, who consumes WCF Service.

For this reason we have SOAP faults, SOAP faults are the way to propagate the exceptions from the service to the client application. .Net has FaultException<T> generic class which can raise SoapFault exception. Service should throw FaultException<T> instead of usual CLR Exception object. T can be any type which can be serialized.

Read more form CodeProject.com

WCF FaultException Caught

File Info (File Properties Window) Extension for Visual Studio

This lightweight extension lets you display the file properties window by a single click from Visual Studio’s Editor. This tool can be accessed from bottom right corner of the File Editor.. Read More

File Properties Window directly from Visual Studio IDE

Interested to see how to create an extension like this then read “Getting started with Visual Studio Editor Viewport Adornment Extensions” from CodeProject.com.

(Instant) Desktop Color Picker.

If you are a Visual Studio developer then you might be interested in Color Picker plugin for Visual Studio. If you are working in other tools where you require color codes then you might wanted to have a Desktop Color Picker, for that I have extended the Color Picker  for Desktop users.

(Instant) Desktop Color Picker UI looks like below,

Integrated Color Picker for Visual Studio IDE

Desktop Color Picker offers the below options,

  • Color Selection from Color Canvas.
  • Color Selection from Available Colors.
  • Color Selection from Standard Colors.
  • Color Selection from Saved Colors.
  • Color Selection using Eyedropper.
  • Copy\Paste Color codes (Name, Hex, #Hex, RGBA and ARGB)

Read more from Desktop Color Picker page.

File Path On Footer Extension 1.4.2 released with Fixes.

I just released File Path On Footer Extension version 1.4.2 with some fixes, Change log is given below for your reference.

Change log

Version 1.4.2

Fixed – Unwanted exception message was showing on Web Essentials Preview Pane of .LESS file.
Version 1.4.1

Fixed – underscore (_) was not showing in file path.
Version 1.4

Fixed font change in Conditional Breakpoint window.
Fixed an issue in .sql file.
Exception handlers are updated to show detailed error descrition, if any.
Version 1.3

Fixed Invalid text in Conditional Breakpoint and Quick Watch window.
Version 1.2

Added support to 11 Visual Studio Themes
Version 1.1

Added support to more files.
Version 1.0

Initial Version

Click here to Download

File Path On Footer Extension for Visual Studio

Integrated Color Picker 1.1 released for Visual Studio IDE.

I just released Color Picker version 1.1 with cosmetic and functional changes.

The New look is here,

Integrated Color Picker for Visual Studio IDE

If you see the below UI, you will get an idea about the UI changes. Thanks Martin and Eric for the suggestions.

Integrated Color Picker for Visual Studio

Apart from the UI change, I have removed color canvas control ( Extended WPF toolkit) from this version to fix style issue in windows 8 environment.

Integrated Color Picker for Visual Studio IDE offers the below options,

  • Color Selection from Color Canvas.
  • Color Selection from Available Colors.
  • Color Selection from Standard Colors.
  • Color Selection from Saved Colors.
  • Color Selection using Eyedropper.
  • Copy\Paste Color codes (Name, Hex, #Hex, RGBA and ARGB)

Read more from Color Picker Page.