Unable to load the native components of SQL Server Compact

HasanG picture HasanG · Jul 21, 2011 · Viewed 26.8k times · Source

I've installed SQL Server Compact Edition 4.0 on Win7 x64 and it runs both for Asp.Net and Desktop Applications. This PC also have Visual Studio 2010 SP1 installed. But my Server 2008 R2 produces following error for Asp.Net applications, although it can run Desktop Applications:

Unable to load the native components of SQL Server Compact corresponding to the
ADO.NET provider of version 8482. Install the correct version of SQL Server
Compact. Refer to KB article 974247 for more details.

I've tried both with a SqlDataSource and SqlCeConnection. Same error. My web.config is like below:

<?xml version="1.0"?>
<configuration>
    <connectionStrings>
       <add name="SQLCE" connectionString="Data Source=|DataDirectory|\a.sdf"
        providerName="System.Data.SqlServerCe.4.0" />
    </connectionStrings>
    <system.web>
        <compilation debug="true" targetFramework="4.0">
            <assemblies>
                <add assembly="System.Data.SqlServerCe, Version=4.0.0.0,
                Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
            </assemblies>
        </compilation>
    </system.web>
</configuration>

Also tried to copy dll's as sugested here but no effect.

Answer

HasanG picture HasanG · Jul 31, 2011

Finally got SQL Server Compact Edition 4.0 working under IIS 7.5. The problem was permission issue. Current Application Pool's identity IWAM_plesk(default) didn't have access to SQL Server Compact 4.0 folders:

C:\Program Files\Microsoft SQL Server Compact Edition\v4.0

C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v4.0

I just granted Read & Execute and List Folder Contents permissions and now it works like a charm.