Invoking custom WCF service from under Sharepoint 2010 throws an Impersonation error from SQL

I had a problem with one of my WCF services that was running under Sharepoint 2010. The problem was that when that service tries to access the database to add a record, i got the below exception.

System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 – Either a required impersonation level was not provided, or the provided impersonation level is invalid.)

It was very weird for me because my connection string was configured to use SQL authentication. So I do not understand why is it trying to impersonate.

Anyways, I have done a simple workaround to overcome that problem. I simply disabled the shared memory provider from the SQL configuration manager.


That way I forced it to work via named pipes. And it worked :). Still I do not know understand what was the problem originally, however, it worked.