无法加载 SQL Server Compact 的本机组件
我已经在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
终于让 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.
在 ASP.net 中部署 SQL Server CE 4.0 有两种方法。
中等信任,或
私有部署。
您的配置文件使用版本 4.0.0.0 -
这需要中等信任,并且要求应用程序池用户有权访问
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 中,这将确保加载您的私有副本。您还需要对 Web.config 中的 DbProvider 部分进行相应的更改
There are two ways to deploy SQL Server CE 4.0 in ASP.net.
Medium trust, or
private deployments.
Your configuration file uses version 4.0.0.0 -
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
tobin\
, 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.You will also require a corresponding change in the DbProvider section in Web.config
您的服务器是否安装了 SQL CE 4.0 测试版?检查“添加/删除程序”以获取版本信息。
Does you server have a beta version of SQL CE 4.0 installed? Check Add/Remove Programs for version info.
Microsoft 知识库位于 http://support.microsoft.com/kb/974247/en-us 说的是:
Microsoft Knowledge Base here http://support.microsoft.com/kb/974247/en-us says this:
我发现了一个完全不相关的问题会导致此错误消息,因此我在这里为从 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.
我刚刚从 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!
我遇到了同样的错误“无法加载 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.