Welcome to SpellCoder Sign in | Join | Help

Solution for the WCF strange problem

Do you remember the problem I faced with WCF before
I found out a way to solve this, first the problem was the ServiceHost is creating a new instance from the Service for every message in the queue, so if the service has a function that uses any exclusive resource like files, this will make the whole process fails, because once one of the instances takes the resource, the rest instances will fail and unexpected behavior will happen, so I found a property in the ServiceBehavior attribute that takes care of this...

[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]

and this solved the problem well,,
For more information read these articles on MSDN Magazine
http://msdn.microsoft.com/msdnmag/issues/06/06/WCFEssentials/default.aspx
http://msdn.microsoft.com/msdnmag/issues/06/06/ClassToContract/default.aspx
http://msdn.microsoft.com/msdnmag/issues/06/06/ServiceStation/default.aspx

Regards
Published Tuesday, May 23, 2006 1:29 PM by Mohammed Hossam
Filed Under: ,

Comments

No Comments

Anonymous comments are disabled