I have set up SQL Server 2008 R2 on a Windows Server 2008 machine and have created a test database on it and a corresponding publication in order to use merge replication. I have set said publication to cater to SQL Server 2008 and SQL Server CE 3.1 subscribers. I have also installed and configured IIS 7 using this walkthrough.
I am developing a C# application on a different PC that is supposed to copy the data from the SQl Server 2008 R2 database and put it in a local SQL Server CE database via merge replication. However it fails miserably with the following error:
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.
The HResult value by the way is 0x80072F76.
On the server side the IIS logs have the following to contribute;
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 ===============
My code is this:
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));
}
I've done some research and I could find only two reasons for getting this error. One is using a Microsoft ISA server with a specific setting enabled, which I'm not. The other is if the publisher and subscriber are using different versions of SQL Server CE drivers, which they do not. According to the registries both machines are on version 3.5.8080.0 (SQL Server CE 3.5 SP2).
How can I get this to work?
You cannot use replisapi.dll, this is for SQL Server to SQL Server websync, you must use sqlcesa35.dll - see this blog post: http://erikej.blogspot.com/2010/06/walkthrough-configuring-merge.html
User contributions licensed under CC BY-SA 3.0