I am using Visual Studio Community 2015 and trying to do the MSDN walkthrough on how to sync a SQL Server database with a local SQL Server Compact database.
Specifically I am getting a "Missing Method" exception when I try to build the ProvisionClient
component of the walkthrough (https://msdn.microsoft.com/en-us/library/ff928765(v=sql.110).aspx)
The exact error is:
An unhandled exception of type 'System.MissingMethodException' occurred in dnx.host.dll
Additional information: Method not found: 'Void Microsoft.Synchronization.Data.SqlServerCe.SqlCeSyncScopeProvisioning..ctor(System.Data.SqlServerCe.SqlCeConnection, Microsoft.Synchronization.Data.DbSyncScopeDescription)'.
This is my code:
using System.Data.SqlClient;
using System.Data.SqlServerCe;
using Microsoft.Synchronization.Data;
using Microsoft.Synchronization.Data.SqlServer;
using Microsoft.Synchronization.Data.SqlServerCe;
namespace ProvisionClient
{
class Program
{
static void Main(string[] args)
{
// create a connection to the SyncCompactDB database
SqlCeConnection clientConn = new SqlCeConnection(@"Data Source='C:\proj\synctest\SyncSQLServerAndSQLCompact\SyncCompactDB.sdf'");
// create a connection to the SyncDB server database
SqlConnection serverConn = new SqlConnection("Data Source=SHRIMAD\\SQLEXPRESS; Initial Catalog=SyncDB; Integrated Security=True");
// get the description of ProductsScope from the SyncDB server database
DbSyncScopeDescription scopeDesc = SqlSyncDescriptionBuilder.GetDescriptionForScope("ProductsScope", serverConn);
// create CE provisioning object based on the ProductsScope
SqlCeSyncScopeProvisioning clientProvision = new SqlCeSyncScopeProvisioning(clientConn, scopeDesc);
// starts the provisioning process
clientProvision.Apply();
}
}
}
I have noticed that on the line:
// create CE provisioning object based on the ProductsScope
SqlCeSyncScopeProvisioning clientProvision = new SqlCeSyncScopeProvisioning(clientConn, scopeDesc);
If I call the constructor that only has the scopeDesc
, then the exception does not show up, but then if I call the following clientProvision.Apply
with the clientConn
, then I get the missing method exception for the Apply
line.
What am I doing wrong? It looks like it does not want to accept a clientConn
parameter, but without that it can not know what DB to provision.
TIA, this is my first post on StackOverflow!
Sync Framework doesnt support SQL CE 4.0.
Have a look at the workaround i blogged here that uses binding redirects.