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.

The extension name ‘enableWebScript’ is not registered error

While deploying a project I am working on that contain an AJAX enabled WCF service, I got the following error:

Invalid element in configuration. The extension name ‘enableWebScript’ is not registered in the collection at system.serviceModel/extensions/behaviorExtensions.

After hours of searching, it turned out to be that when you run the wcf uninstall command as shown below, it removes with the configurations from the machine.config.

servicemodelreg.exe -u

I found someone who suggested to add the xml tags manually to the machine.config. Although it worked, I got other errors. At the end, I reinstalled .Net FrameWork 3.5 SP1, in order to resolve that issue.