无法加载与ADO.NET提供程序对应的SQL Server Compact的本机组件

Tar*_*ied 20 c# entity-framework sql-server-ce

在我的项目中,我使用SQL CE 3.5数据库与实体框架,并遵循 这篇文章, 但我有这个例外:

无法加载与版本8080的ADO.NET提供程序对应的SQL Server Compact的本机组件.安装正确版本的SQL Server Compact.有关更多详细信息,请参阅知识库文章974247.

所有细节

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: 
Run Code Online (Sandbox Code Playgroud)

Tom*_*zek 32

我通过私有安装SqlServerCE得到了这个错误.我在我的项目中引用了System.Data.SqlServerCe.dll,但我遗漏了SqlServerCE所需的其他dll(本机组件)."本机组件"位于SqlServerCE的"私有"文件夹的x86和amd64子文件夹中.您需要确保将它们复制到项目的输出文件夹中.

  • 这些文件夹在哪里? (2认同)
  • C:\ Program Files \ Microsoft SQL Server Compact Edition \ v4.0 \ Private (2认同)
  • 只是为了向像我这样的人说明,这不是一个天然的游乐场。需要将 C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v4.0\Private 中的 amd64 和 x86 文件夹复制到网站目录的 \bin 或 \Bin 文件夹中。 (2认同)