Tuesday, July 31, 2007

Managing your WCF Service Context & State

Hi Folks,

when you create a host for your service,this host manage the context of the service and its states,for this reason,you have to take care how can you configure your host to keep your service under control without any issues regarding the security or performance.

One point regarding the Service performance which is the Service Context:did u ask your self if 1000 Clients call your service ? how manay instances will be created from your service ?

To answer this question,you have to know which mode are your setting your service to work with.

1) Per Session Mode :

How to Implement : Mark your service class with this attribute

C# : [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]

Answer : 1000 sessions will be created.

2) Per Call Mode :

How to Implement : Mark your service class with this attribute

C# : [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]

Answer : Per call the host will create an instance for your service.
This mode give better performance incase the client still opened and not active rather than the prev. mode.

3) Single Mode :

How to Implement : Mark your service class with this attribute

C# : [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]

Answer : 1 instance and all clients can share data between them.

Hope this helps.

Moustafa arafa

Sunday, July 29, 2007

Breaking and Non-Breaking change on WCF service

Hi Folks,

In this post i want to mention and differentiate between 2 types of changes on any WCF service.

when you are developing a wcf servive,the changes might occur,and before any change you have to test and examine does this change will affect the service clients ?

The changes you have done on a WCF Service,it will affect the client anyway,but the type of the change it might break the client which yield to the client will not work OR it might yield to the client can continues working in a healthy way.

NON Breaking Changes:
Implicit or Explict security checks,change on the logic of the function,add extra binding configuration...etc

Breaking Changes:
Change Method paramaters , Add new paramaeters,change return types,delete methods.

Any Change which will break the client,you have to inform the client owner with the change you have done,to keep the client working.

Hope this helps.

Moustafa arafa

Wednesday, July 25, 2007

Monitor your WCF Services

Hi Folks,

if you are a WCF Developer / Analyst,and you want to trace all messages between your WCF Services and theri clients,MS Provide a tool to monitor and trace all SOAP Messages between the services and its clients called "Service Trace Viewer"

TO Open Service Trace Viewer Tool :

C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin), and then type SvcTraceViewer.exe.

Files Supported by this tool :
**WCF Tracing File (.svcLog) -> this will be used for tracing purposes on your WCF Apps.

**Event Tracing File (.etl)
**Crimson Tracing File

Read more on Service Trace Viewer :

Moustafa arafa

Thursday, July 19, 2007

New SDKs : WSS 3.0 SDK & MOSS 2007 SDK

Hi Folks,

New SDKs has been released for SBS 2007 and for WSS 3.0.

Download link :

SBS 2007 SDK :

WSS 3.0 SDK :


Moustafa arafa

Tuesday, July 17, 2007

Top 10 Gems in SQL 2005

Hi All,

Excellent article which highlight some features on SQL 2005 which weren't get the spot on the webcasts,articles and SQL Demos.


Thanks my Friend ali Riza for his useful post.

Hope this helps.......... :)

Moustafa arafa

Monday, July 16, 2007

Bug on VS 2005 on installing the default installer

Hi Folks,

if you create your windows service,and u add the project deployment package and you try to install it from the VS.Net by right click on the deployment packge and install,this will not show the service in the services list on windows,even the installer says the service has been successfully installed.

the only thing u can do to install your service in the services in windows,run this command :


this will show the service on the services list.

Hope this help.

Moustafa arafa

Deploy a windows service in VS 2005

Hi Folks,

Below article show how to develop/Debug and deploy a windows service.


Hope this helps.

Moustafa arafa

Mid function in VB.net for C# Guys

Hi C# Devs,

I want to convert one of the vb.net code functions to a c# solution for some requirments ,i found on the code the usage of Mid function as one of the important functions on the string manipulation for vb.net developers; as a C# guy,i need an equivelant to it,simply replace the mid function with the following :

VB.Net :
str2= Mid(str1, 1, Len(str1) - 1)
C# :

substring function is the equivelant to Left,Right,Mid functions for VB.Net developers.

VIVA C#.................. :)

Moustafa arafa

Tuesday, July 10, 2007

Recover SQL 2005 DB passwords

Hi Folks,

I got an urgent request of one of my friends asking for a solution to recover SQL 2005 DB passwords,the situation was as follows:

He took a backup of SQL 2005 DB and set the password option on SQL 2005,and when he tried to restore the DB,SQL 2005 request the password which he forgot it.

My First question was: did he protect the bak file from SQL 2005 or not ? after i got that he protect the DB from SQL 2005,i started to search for third party solution to fix this problem since this DB contains very sensitive information.

I found a third party to recover the SQL 2005 user accounts passwords ,try it now :

The security hole which i discovered that this program can't recover the SQL server passwords if the SQL Engine was configured to use only Windows Authentication Mode; and this is considered as an important security point when we use MS Products with Windows Authentication mode ONLY.

From this post,you have to take care of your SQL installation which mode is an appropriate to your organization.
Hope this helps.

In case you put the password on the bak file,then no way to do any kind of restore to this DB;see more on this article : http://mssqltips.com/tip.asp?tip=1108

Moustafa arafa

Sunday, July 08, 2007

Protecting your WCF Service

Hi Folks,

.Net Framework built a robust framework for building distributed application by providing different security means to protect your WCF Service.

you can protect your WCF Service by 3 different ways which is most requested for all different kind of applications :

1) Windows Role Token group based on Active Directory Group.
2) SQL Role Provider: user roles stroed in a DB.
3) Authorization Role Provider : using MS Authorization manager tool.
** This tool let you store the roles in the AD or XML file.

Happy .netting.

Moustafa arafa

Monday, July 02, 2007

.Net 3.0 & .Net 2.0 Design Tips

On the above figure it shows the following:

1) New Technologies coming with .net 3.0 Framework (CF,WF,PF,CardSpace).

2) The Base of .Net Framework 3.0 working on the .Net Framework 2.0,this means any application on 2.0 will not have any interoperability issues or problem to work on .net 3.0 unlike the shift between .net 1.0 to 2.0.

3) Move from Web services to WCF :
-System.ServiceModel is the namespace which provides the whole funcaitonality of WCF.
-Implementing the interface and the implementaiton clsses to implement a WCF service.
(Service Contract,Operation Contract,DataContract)
- Binding information on the web.config,Transport protocol,Endpoints information.

- using svcUtil tool to create proxy classes and clients to your service.

-Integration with COM+,WS,MSMQ,.Net Remoting....etc with WCF