SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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);
share|improve this question

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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