我在 Visual Studio 2008 中使用 .net 3.5 设置了一个项目,该项目具有一个组件,可将数据从我的 sqlserver 同步到客户端 sqlce 数据库(SDF 文件)。一切正常,直到我决定将项目升级到 Visual Studio 2010,现在以下代码崩溃:
try
{
MySyncAgent syncAgent = new MySyncAgent(filter);
SyncStatistics syncStats = syncAgent.Synchronize(); //this crashes
}
我得到的异常是:EXCEPTION MESSAGE = [OBJECT REFERENCE NOT SET TO an instance of an OBJECT.] : STACKTRACE = [ AT SYSTEM.DATA.SQLSERVERCE.SQLCECHANGETRACKING.UPGRADEPUBLICTRACKING(STRING CONNECTIONSTRING) AT MICROSOFT.SYNCHRONIZATION.DATA.SQLSERVERCE.SQLCECLIENTSYNCPROVIDER .PERFORMUPGRADEIFNECESSARY() AT MICROSOFT.SYNCHRONIZATION.DATA.SQLSERVERCE.SQLCECLIENTSYNCPROVIDER.BEGINTRANSACTION(SYNCSESSION SYNCSESSION) AT MICROSOFT.SYNCHRONIZATION.SYNCAGENT.DATASYNCHRONIZE() AT MICROSOFT.SYNCHRONIZATION.SYNCAGENT.SYNCHRONIZE()
我错过了什么?
作为参考,我的 MySyncAgent 类构造函数如下所示:
public class MySyncAgent : Microsoft.Synchronization.SyncAgent
{
public MySyncAgent(string filter)
{
this.InitializeSyncProviders(filter);
this.InitializeSyncTables();
}
}