C# 无法加载与 ADO.NET 提供程序对应的 SQL Server Compact 的本机组件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12226530/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider
提问by Tarek Saied
In my project, I use SQL CE 3.5 database with entity framework and followed this articlebut i have this exception :
在我的项目中,我使用带有实体框架的 SQL CE 3.5 数据库并遵循了 这篇文章,但我有这个例外:
Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8080. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details.
无法加载与版本 8080 的 ADO.NET 提供程序相对应的 SQL Server Compact 的本机组件。安装正确版本的 SQL Server Compact。有关更多详细信息,请参阅知识库文章 974247。
All details
所有细节
System.Data.SqlServerCe.SqlCeException was unhandled
Message=Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8080. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details.
Source=""
HResult=-1
NativeError=-1
StackTrace:
at System.Data.SqlServerCe.NativeMethods.LoadNativeBinaries()
at System.Data.SqlServerCe.SqlCeConnection..ctor()
at System.Data.SqlServerCe.SqlCeProviderFactory.CreateConnection()
at System.Data.EntityClient.EntityConnection.GetStoreConnection(DbProviderFactory factory)
at System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString)
at System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName)
at DAL.OimDBEntities..ctor()
at DAL.OimRepository..ctor()
at Microsoft.Rtc.Collaboration.Sample.SubscribePresenceView.UCMASampleSubscribePresenceView.Subscribe()
at Microsoft.Rtc.Collaboration.Sample.SubscribePresenceView.UCMASampleSubscribePresenceView.Run()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.DllNotFoundException
Message=Unable to load DLL 'sqlceme35.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Source=System.Data.SqlServerCe
TypeName=""
StackTrace:
at System.Data.SqlServerCe.NativeMethods.GetSqlCeVersionInfo(IntPtr& pwszVersion)
at System.Data.SqlServerCe.NativeMethods.LoadValidLibrary(String modulePath, Int32 moduleVersion)
at System.Data.SqlServerCe.NativeMethods.LoadNativeBinaries()
InnerException:
回答by Ashish Gupta
I also had encountered the same problem. the problem was i had used the following command install-package EFcodeFirst.SqlServerCompact to get the sqlCE. the version that was downloaded by package manager was 4.0 and whereas on my harddisk the version present was 3.5
我也遇到过同样的问题。问题是我使用了以下命令 install-package EFcodeFirst.SqlServerCompact 来获取 sqlCE。包管理器下载的版本是 4.0,而我的硬盘上的版本是 3.5
download the latest version 4.0 from the following location http://www.microsoft.com/en-us/download/details.aspx?id=17876did solved my problem
从以下位置下载最新版本 4.0 http://www.microsoft.com/en-us/download/details.aspx?id=17876确实解决了我的问题
回答by Tom Andraszek
I got this error with a private install of SqlServerCE. I had a reference to System.Data.SqlServerCe.dll in my project, but I was missing other dlls (native components) needed by SqlServerCE. The "native components" are in x86 and amd64 subfolders of SqlServerCE's "private" folder. You need to make sure that they get copied to the output folder of your project.
我在私人安装 SqlServerCE 时遇到了这个错误。我在我的项目中引用了 System.Data.SqlServerCe.dll,但我缺少 SqlServerCE 所需的其他 dll(本机组件)。“本机组件”位于 SqlServerCE 的“私有”文件夹的 x86 和 amd64 子文件夹中。您需要确保将它们复制到项目的输出文件夹中。
回答by martijn
I had a similar problem. I was opening a compact framework sql database and it gave me the following error:
我有一个类似的问题。我正在打开一个紧凑的框架 sql 数据库,它给了我以下错误:
Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8080. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details.
无法加载与版本 8080 的 ADO.NET 提供程序相对应的 SQL Server Compact 的本机组件。安装正确版本的 SQL Server Compact。有关更多详细信息,请参阅知识库文章 974247。
When looking up the article, it led me to the following Link. The following quote explains what went wrong:
查找文章时,它使我找到了以下链接。以下引述解释了出了什么问题:
Compact based applications generally program against the Compact ADO.NET provider (System.Data.SqlServerCe.dll). This provider in-turn communicates with the native Compact components. In order to avoid various inconsistencies, a Compact ADO.NET provider of a certain version can talk only to the Compact native components of the same version.
基于 Compact 的应用程序通常针对 Compact ADO.NET 提供程序 (System.Data.SqlServerCe.dll) 进行编程。此提供程序依次与本机 Compact 组件进行通信。为了避免各种不一致,某个版本的Compact ADO.NET提供者只能与同版本的Compact原生组件对话。
In the end I solved it by downloading and installing the service pack in the following link.
回答by Dhanik Lal Sahni
You will need to copy the following file and entire directory to the location where your .exe is running on your server. This file and folder are most likely in the directory C:\Program Files(x86)\Microsoft SQL Server Compact Edition\V4.0\Private
您需要将以下文件和整个目录复制到您的 .exe 在您的服务器上运行的位置。此文件和文件夹很可能位于目录 C:\Program Files(x86)\Microsoft SQL Server Compact Edition\V4.0\Private
System.Data.SqlServerCe.dll The entire amd64 folder I'm not sure what is used from the amd64 folder, but as soon as I copied this over my application started to work. You could also get your System.Data.SqlServerCe.dll file by clicking on it in Visual Studio under the References folder and then in the properties tab setting “Copy Local” to True and then when you build your app that file will be in your release folder.
System.Data.SqlServerCe.dll 整个 amd64 文件夹我不确定 amd64 文件夹中使用了什么,但是一旦我将其复制到我的应用程序上就开始工作。您还可以通过在 Visual Studio 中的 References 文件夹下单击它来获取 System.Data.SqlServerCe.dll 文件,然后在属性选项卡中将“Copy Local”设置为 True,然后当您构建应用程序时,该文件将位于您的发布文件夹。

