I have a custom Sharepoint WCF Service that does database calls using ADO.NET.

I have tried just about everything I can, but everytime I call the SqlConnection.Open() method, I get this exception:

Could not load file or assembly 'System.EnterpriseServices, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Either a required impersonation level was not provided, or the provided impersonation level is invalid. (Exception from HRESULT: 0x80070542)

Things I've tried: New WCF Service,New database, different Connection Strings, hard code connection strings, all produce the same exception

My code sample below:

public string HelloWorld()
    string _connectionString = @"Data Source=localhost\SharePoint;Initial Catalog=Test;Integrated Security=SSPI;"; 

    SqlConnection dbConnection;
    SqlDataAdapter dbAdapter;
    SqlCommand dbCommand;
    DataTable dtResults;

    dbConnection = new SqlConnection(_connectionString);
    dbCommand = new SqlCommand("GetTest", dbConnection);
    dbCommand.CommandType = CommandType.StoredProcedure;

    dbAdapter = new SqlDataAdapter(dbCommand);
    dtResults = new DataTable("Results");

        return dtResults.Rows[0][0].ToString();
    catch (Exception ex)
        throw new Exception(ex.Message);

1 Answer 1


This error actually has nothing to do with your service itself. It's a permissions problem.

The issue is outlined here: Could not load file or assembly System.EnterpriseServices

Essentially, the Claims Service Account needs the "Act as part of the Operating System" policy (Act as part of the operating system), and then you need to restart the Claims to Windows Token Service and perform an IIS Reset.

Should work smooth as butter after that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.