无法加载 SQL Server Compact 的本机组件

发布于 2024-11-25 07:18:35 字数 1277 浏览 1 评论 0原文

我已经在 Win7 x64 上安装了 SQL Server Compact Edition 4.0,它可以运行于 Asp.Net 和桌面应用程序。此 PC 还安装了 Visual Studio 2010 SP1。但是我的 Server 2008 R2 对 Asp.Net 应用程序产生以下错误,尽管它可以运行桌面应用程序:

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.

我已经尝试使用 SqlDataSource 和 SqlCeConnection。同样的错误。我的 web.config 如下所示:

<?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>

还尝试按照建议复制 dll 此处 但没有效果。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

離殇 2024-12-02 07:18:35

终于让 SQL Server Compact Edition 4.0 在 IIS 7.5 下工作了。问题是权限问题。当前应用程序池的标识 IWAM_plesk(默认)无权访问 SQL Server Compact 4.0 文件夹:

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

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

我刚刚授予了 Read & 权限。执行并列出文件夹内容权限,现在它就像一个魅力。

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.

歌入人心 2024-12-02 07:18:35

在 ASP.net 中部署 SQL Server CE 4.0 有两种方法。

  1. 中等信任,或

  2. 私有部署。

您的配置文件使用版本 4.0.0.0 -

<add assembly="System.Data.SqlServerCe, Version=4.0.0.0,
            Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>

这需要中等信任,并且要求应用程序池用户有权访问 C:\Program Files\Microsoft SQL Server Compact Edition 中的 SQL Server Compact COM dll。

如果中等信任失败,您可以尝试私有部署。这是我的偏好,并且您的系统将来出现问题的可能性较小。

如果您私有部署 SQL Server CE DLL,请通过将 v4.0\Private 中的所有文件复制到 bin\ 来确保您的 Web .config 声明对版本 4.0.0.1 的依赖。此版本未部署在 GAC 中,这将确保加载您的私有副本。

<system.web>
 <compilation>
  <assemblies>
    <add assembly="System.Data.SqlServerCe, Version=4.0.0.1,
            Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
  </assemblies>
 </compilation>
</system.web>

您还需要对 Web.config 中的 DbProvider 部分进行相应的更改

<system.data>
    <DbProviderFactories>
        <remove invariant="System.Data.SqlServerCe.4.0" />
        <!-- Use private copy 4.0.0.1 -->
        <add invariant="System.Data.SqlServerCe.4.0" 
             name="Microsoft SQL Server Compact 4.0"
             description=".NET Framework Data Provider for Microsoft SQL Server Compact"
             type="System.Data.SqlServerCe.SqlCeProviderFactory,
                   System.Data.SqlServerCe,
                   Version=4.0.0.1,
                   Culture=neutral,
                   PublicKeyToken=89845dcd8080cc91" />
    </DbProviderFactories>
</system.data>

There are two ways to deploy SQL Server CE 4.0 in ASP.net.

  1. Medium trust, or

  2. private deployments.

Your configuration file uses version 4.0.0.0 -

<add assembly="System.Data.SqlServerCe, Version=4.0.0.0,
            Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>

this requires Medium Trust, and requires the App Pool user having permission to access the SQL Server Compact COM dlls in C:\Program Files\Microsoft SQL Server Compact Edition.

Where medium trust fails, you could attempt private deployment. This is my preference and there's less chance something will go wrong with your system sometime in the future.

If you private deploy the SQL Server CE DLLs, by copying all the files in v4.0\Private to bin\, make sure your Web.config declare a dependency on version 4.0.0.1. This version is not deployed in the GAC and this will ensure your private copy gets loaded.

<system.web>
 <compilation>
  <assemblies>
    <add assembly="System.Data.SqlServerCe, Version=4.0.0.1,
            Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
  </assemblies>
 </compilation>
</system.web>

You will also require a corresponding change in the DbProvider section in Web.config

<system.data>
    <DbProviderFactories>
        <remove invariant="System.Data.SqlServerCe.4.0" />
        <!-- Use private copy 4.0.0.1 -->
        <add invariant="System.Data.SqlServerCe.4.0" 
             name="Microsoft SQL Server Compact 4.0"
             description=".NET Framework Data Provider for Microsoft SQL Server Compact"
             type="System.Data.SqlServerCe.SqlCeProviderFactory,
                   System.Data.SqlServerCe,
                   Version=4.0.0.1,
                   Culture=neutral,
                   PublicKeyToken=89845dcd8080cc91" />
    </DbProviderFactories>
</system.data>
作业与我同在 2024-12-02 07:18:35

您的服务器是否安装了 SQL CE 4.0 测试版?检查“添加/删除程序”以获取版本信息。

Does you server have a beta version of SQL CE 4.0 installed? Check Add/Remove Programs for version info.

梦在深巷 2024-12-02 07:18:35

Microsoft 知识库位于 http://support.microsoft.com/kb/974247/en-us 说的是:

在任何给定时间点,64 位计算机的正确状态,
对于 SQL Server Compact,将是以下内容:x86 和 amd64
MSI 已安装。 x86 和 amd64 MSI 的版本相同。

因此,如果您遇到任何类似问题,请确保计算机
同时安装了 Compact 的 x86 和 amd64 MSI,并且它们是
相同的版本。如果不是,请安装 Compact SP2 x86
以及根据需要从以下链接获取 x64 MSI:
http://www.microsoft.com/downloads/details.aspx?familyid=E497988A-C93A-404C-B161-3A0B323DCE24&displaylang=en

Microsoft Knowledge Base here http://support.microsoft.com/kb/974247/en-us says this:

At any given point of time, the correct state of a 64-bit computer,
for SQL Server Compact, would be the following: Both x86 and amd64
MSIs are installed. Both x86 and amd64 MSIs are of the same version.

Therefore, if you face any similar issues, make sure that the computer
has both x86 and amd64 MSIs of Compact are installed and they are of
the same version. In case, they are not, then install Compact SP2 x86
and x64 MSIs from following link as needed:
http://www.microsoft.com/downloads/details.aspx?familyid=E497988A-C93A-404C-B161-3A0B323DCE24&displaylang=en

桜花祭 2024-12-02 07:18:35

我发现了一个完全不相关的问题会导致此错误消息,因此我在这里为从 Google 到达这里的任何人发布了一个链接。这花了昨晚大约三四个小时,我最终不得不逐步完成反编译的 SqlServerCe 二进制文件,所以希望这会对您有所帮助:应用程序路径中的某些符号阻止 SQL Server Compact从加载

I discovered a completely unrelated issue that would cause this error message, so I'm posting a link here for anyone who arrived here from Google. This ate up about three or four hours of last night, and I eventually had to step through the decompiled SqlServerCe binaries, so hopefully this will help you: Certain symbols in application path prevent SQL Server Compact from loading.

不忘初心 2024-12-02 07:18:35

我刚刚从 SQL CE 3.5 升级到 4.0,通过从 微软
执行此操作后,我收到了将我带到这里的错误消息。
对我来说,解决方案是使用 NuGet 包管理器为 EntityFramework 安装 SQL CE 4.0。因此,仅从网站安装二进制文件对我来说并不起作用!

I just upgraded from SQL CE 3.5 to 4.0, by downloading a new version from Microsoft.
After doing this, I received the error message which brought me here.
For me the solution was to install SQL CE 4.0 for EntityFramework as well, by using the NuGet package manager. So only installing the binaries from the website didn't do the trick for me!

红焚 2024-12-02 07:18:35

我遇到了同样的错误“无法加载 SQL Server Compact 的本机组件”

我使用了 Try Catch 内置对象并解决了该问题。我尝试打开的 sdf 文件有密码。

I had the same error 'Unable to load the native components of SQL Server Compact'

I have used the Try Catch inbuilt objects and solved the problem. The sdf file what i tried to open had a password.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文