Interesting related videos


Thursday, April 17, 2008

How to add custom http header in WCF

If you want to add custom http header web service calls, there is a simple way to do it in WCF. Here is the code:

MessageHeader header
= MessageHeader.CreateHeader(
"Custom Header."

using (Service1Client client = new Service1Client())
using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))

HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
httpRequestProperty.Headers.Add("myCustomHeader", "Custom Happy Value.");
httpRequestProperty.Headers.Add(HttpRequestHeader.UserAgent, "my user agent");
OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;


Tuesday, April 15, 2008

ReaderWriterLockSlim Performance - Is it really so slim??!!!

On the .NET 3.5 Microsoft came up with new object named ReaderWriterLockSlim in order to achieve synchronised access to shared resources and also to improve the profermance issues that the old object (System.Threading.ReaderWriterLock) has.

Pedram Rezaei's wrote on his blog great post on Performance Comparison of ReaderWriterLockSlim.
On his performance tests he found that ReaderWriterLockSlim object is slower then the Monitor object.

Pedram Rezaei's conclusion:
"A reader-writer lock allows for multiple concurrent reads to enter a read-lock all at the same time and depending on the scenario, it can significantly improve the overall performance of your application when used instead of a mutual exclusive lock. A read-lock takes a shared lock and a write-lock takes an exclusive lock.

The new ReaderWriterLockSlim correctly gives priority to write requests therefore only use when reads are frequent and writes are less common."

You can take a look on his post here: A Performance Comparison of ReaderWriterLockSlim with ReaderWriterLock

Monday, April 14, 2008

Open VSS 2005 client without enter user name and password

If you want to set VSS (Visual Source Safe) 2005 client default user name and password without type them all the time, you have to do the following steps:
1) right click on VSS 2005 client icon
2) select properties
3) on the "target" at the end add your desire user name and pssword as follow:
So you target shuold look like something like:
"C:\Program Files\Microsoft Visual SourceSafe\ssexp.exe" -YMyUser,123456.

This will open your source safe client with current user without opening the user password screen.

Sunday, April 13, 2008

LINQ to SQL Visual LINQ Query Builder Visual Studio 2008 Add-In

Visual LINQ Query Builder is an add-in to Visual Studio 2008 Designer that helps you visually build LINQ to SQL queries. Functionally it provides the same experience as, for instance the Microsoft Access Query Builder, but in the LINQ domain.
You can read more here:
LINQ to SQL Visual LINQ Query Builder