Monday, June 29, 2009

Running SQL service as console application

This might be a known fact to many of the SQL users. But I did not knew that SQL service can run as a console application which accepts command line parameters for various level of log tracing. Steps for starting SQL service as console application
1. Stope SQL server service.
2. Start sqlserver.exe in console mode using following command
start /realtime sqlserver.exe -c -s YourInstanceName. Omit -s if you are testing with default instance
3. Pass command line parameter to enable trace flag for e.g. to trace event 3505 pass 'T3505'.
You must switch to the appropriate BINN directory for the instance at a command prompt before starting sqlservr.exe. For example, if Instance1 were to use \mssql$Instance1 for its binaries, the user must be in the \mssql$Instance1\binn directory to start sqlservr.exe -s instance1.
SQL server error log file locationSQL 2008 and 2005-> Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\LOG\ERRORLOG and ERRORLOG.n files.

Wednesday, June 17, 2009

Easing The Pain Of WCF Debugging

Recently I came across a nice article about WCF debugging. htttp://davybrion.com/blog/2008/08/easing-the-pain-of-wcf-debugging/. It explains how to enable WCF tracing. It logs all the WCF activities and provides clues for the potential issues. Error tracing is quite detailed. It actually helped me a in resolving few issues related to unhanlded exceptions. The exception message text is quite detailed and sometimes gives the clue about the solution. Quit helpful and must know for every WCF developer.

WCF error: System.ServiceModel.CommunicationException: The socket connection was aborted

I wrote my first WCF service recently which supported tcp as a transport protocol. During testing I faced a very strange problem. The service used to work for sometime and then suddenly would start throwing Communication exception.
System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host
This error was very annoying and there was no clue what is going wrong. While googling for this, I came across some posts which talked about this issue. Every WCF channel has a receive timeout whose value is picked up from the app.config file when you add proxy for the service. If there is no activity during this timeout then WCF closes underlying socket and so further call on the channel throws Communication exception.
To resolve this issue, set the receive timeout to appropriate value at both client as well as server endpoints. You can use 'infinite' keyword to suggest WCF to use TimeSpan.MaxValue value. 'infinite' keyword is not recognized by Visual Studio editor and would show error for that which can be safely ignored. Another way to set infinite timeout is programmatically. At both endpoints (i.e. at client and server) set the endpoint's receivetimeout propery to TimeSpan.MaxValue.
Below is good posts on the same issue -
http://social.msdn.microsoft.com/forums/en-US/wcf/thread/06cb1522-31f0-4ce3-85f0-02656228a8e1/