WCF RESTful Service      Interview Questions         WCF Bindings             WCF Tracing                              

Thursday, May 31, 2012

.NET Exceptions Vs Faults


Exception is a .NET mechanism used to communicate problems encountered during the execution of a program. Various .NET languages allows us to throw, catch/handle or possibly ignore exceptions so that they can be further propogated up to the call stack.


While Fault refers to SOAP fault mechanism that transfers erros or fault condition from service to consumer according to SOAP Specifications.

In Windows Communication Foundation, its always very helpful to diagnose problems during development phase.



Be social and share with others via:


.NET Jobs from Indeed
Reader of this article might also be interested in:

By Imran Abdul Ghani
Software Developer (Senior)
United Arab Emirates
Imran Abdul Ghani is working as Software Developer(Senior) with extensive knowledge in Web development technologies especially C#, ASP.NET, MVC, WCF, Web API, ADO.NET Entity Framework, jQuery etc. He has several years of experience in designing/developing enterprise level applications. He is Microsoft Certified Solution Developer for .NET (MCSD.NET) since 2005. You can reach his blogging at www.webdevelopmenthelp.net & www.topwcftutorials.net.

WCF Service - What is a KnownType?

In Windows Communication Foundation, a KnownType is the acceptable derived class for a given Data Contract.
For the purpose of understanding in this WCF Tutorial, lets take an example. Consider the following Data Contract classes having inheritance relationship as follows:
   [DataContract]
   public class UserAccount {}

   [DataContract]
   public class Admin : UserAccount {}

   [DataContract]
   public class Guest : UserAccount {}

Now, look into following code:
  [DataContract]
  [ServiceKnownType(typeof(Admin))]
  [ServiceKnownType(typeof(Guest))]
  public class SecurityInfo
  {
          [DataMember]
          private UserAccount user;
  }

Above code will work fine, either we set SecurityInfo data member to Admin or Guest.
But if KnownTypeAttribute for Admin and Guest are not provided, deserialization engine will not recognize Admin and Guest types and will cry.

For more detailed understanding with example of all possible ways of associating Known Types in WCF, Click Here.


Be social and share with others via:


Other WCF and Web Tutorial with Examples:
.NET Jobs from Indeed

By Imran Abdul Ghani
Software Developer (Senior)
United Arab Emirates
Imran Abdul Ghani is working as Software Developer(Senior) with extensive knowledge in Web development technologies especially C#, ASP.NET, MVC, WCF, Web API, ADO.NET Entity Framework, jQuery etc. He has several years of experience in designing/developing enterprise level applications. He is Microsoft Certified Solution Developer for .NET (MCSD.NET) since 2005. You can reach his blogging at www.webdevelopmenthelp.net & www.topwcftutorials.net.