1

我已经在 Windows Server 2008 机器上设置了 SQL Server 2008 R2,并在其上创建了一个测试数据库和一个相应的发布,以便使用合并复制。我已将上述出版物设置为迎合 SQL Server 2008 和 SQL Server CE 3.1 订阅者的需求。我还使用演练安装和配置了 IIS 7。

我正在另一台 PC 上开发 C# 应用程序,它应该从 SQl Server 2008 R2 数据库中复制数据,并通过合并复制将其放入本地 SQL Server CE 数据库中。但是,它因以下错误而惨遭失败:

A first chance exception of type 'System.Data.SqlServerCe.SqlCeException' occurred in System.Data.SqlServerCe.dll
Internal error: HTTP header information is either corrupted or missing in the transport message. It could be a network transmission error or an IIS problem.

顺便说一下,HResult 值是 0x80072F76。

在服务器端,IIS 日志有以下贡献;

CReplicationListenerWorker    , 2012/03/03 02:21:14.939, 3400,   174,  S2, INFO: =============== START PROCESSING REQUEST ==============
CategorizeRequest             , 2012/03/03 02:21:14.940, 3400,    93,  S1, ERROR: GetMessageListenerObject failed, hr = 0x80070057
CReplicationListenerWorker    , 2012/03/03 02:21:14.940, 3400,   261,  S2, WARN: CategorizeRequest failed, hr = 0x80004005.
CReplicationListenerWorker    , 2012/03/03 02:21:14.940, 3400,   262,  S2, WARN: Generating default web page.
CReplicationListenerWorker    , 2012/03/03 02:21:14.940, 3400,   396,  S2, INFO: =============== DONE PROCESSING REQUEST ===============

我的代码是这样的:

SqlCeReplication repl = new SqlCeReplication();
repl.InternetUrl = "https://winserver2008/SQLReplication/replisapi.dll";
repl.InternetLogin = "SQL";
repl.InternetPassword = "somepassword";
repl.Publisher = "WINSERVER2008";
repl.PublisherDatabase = "Test";            
repl.PublisherSecurityMode = SecurityType.DBAuthentication;
repl.Publication = "TestPublish";
repl.Subscriber = "Dev System";
repl.SubscriberConnectionString = "Data Source=" + dbFilePath;
repl.DistributorLogin = "SQL";
repl.PublisherLogin = "SQL";
repl.DistributorAddress = "192.168.232.128";

if (File.Exists(dbFilePath)) { 
    File.Delete(dbFilePath);
}
repl.AddSubscription(AddOption.CreateDatabase); //Create new db

try{
    repl.Synchronize();
} catch (SqlCeException e) {
    Console.WriteLine(e.Message + " - HResult: " + String.Format("{0:X}", e.HResult));
}

我做了一些研究,我只能找到导致此错误的两个原因。一种是使用启用了特定设置的 Microsoft ISA 服务器,但我没有。另一种情况是发布者和订阅者使用不同版本的 SQL Server CE 驱动程序,而他们没有这样做。根据注册表,两台机器的版本均为 3.5.8080.0(SQL Server CE 3.5 SP2)。

我怎样才能让它工作?

4

1 回答 1

1

您不能使用 replisapi.dll,这是用于 SQL Server 到 SQL Server websync,您必须使用 sqlcesa35.dll - 请参阅此博客文章:http ://erikej.blogspot.com/2010/06/walkthrough-configuring-merge.html

于 2012-03-03T04:15:42.483 回答