locked
NullReferenceException at Microsoft.Synchronization.Services.SqlProvider.SqlSyncProviderService.CreateNewScopeForClient() RRS feed

  • Question

  • Since the updated bits have arrived i've been trying everything to get on with my scenario but i did not succeed yet. After days of trying and searching i have boiled it down to a very basic example and it still fails. Unfortunatly the only response i receive from my service this time is "Internal server error" - and not a single bit of information more.

    Here are the details:

    1. Provisioned an existing database with the following scope config:

     

      <SyncScope Name="DefaultScope" IsTemplateScope="true">
    <SyncTables>

    <SyncTable Name="MyTable" GlobalName="Foo" IncludeAllColumns="false" FilterClause="[side].DeviceNo = @DeviceNo">
    <SyncColumns>
    <SyncColumn Name="SomeID" IsPrimaryKey="true" IsNullable="false" SqlType="uniqueidentifier" />
    <SyncColumn Name="DeviceNo" IsNullable="false" SqlType="varchar" />
    <SyncColumn Name="SomeVal" IsNullable="false" SqlType="int"/>
    <SyncColumn Name="OtherVal" IsNullable="false" SqlType="int"/>
    </SyncColumns>
    <FilterColumns>
    <FilterColumn Name="DeviceNo"/>
    </FilterColumns>
    <FilterParameters>
    <FilterParameter Name="@DeviceNo" SqlType="varchar" DataSize="20"/>
    </FilterParameters>
    </SyncTable>

    </SyncTables>
    </SyncScope>

     

    As one can see in the scope definition not all columns are defined for sync. Among the other columns there are some of type bit, too.

    2. Created a simple webservice exactly as described in the walktrough docs. Deployed it in IIS (Windows 7 x64).

    3. Created a very simple silverlight client exactly as describe in the walktrough docs. Deployed it in IIS, too.

    4. Set up fiddler to sniff HTTP traffic. Found the following response when trying to sync:

     

    <ServiceError xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Synchronization.Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ErrorDescription>Internal Server Error</ErrorDescription></ServiceError>

     

    Due to this speechlessness of the server i have no idea whats actually going wrong. Would it be possible to receive debug symbols for the Microsoft.Synchronization.Services.dll ?

    Besides asking on the actual problem it also leads to a very important feature request: be more explicit in server error responses and make sure this information actually makes it through to the silverlight layer.

     

    • Edited by M.Bi Tuesday, July 27, 2010 7:08 AM
    Friday, July 23, 2010 7:24 AM

Answers

  • The table MyTable was provisioned with GlobalName="Foo" and the AddFilterParameterConfiguration method must reference it using the global name "Foo" and not the local name "MyTable". Please change the following line and your issue should be fixed.

     config.AddFilterParameterConfiguration("deviceno", "MyTable", "@DeviceNo", typeof(System.String));

    to

     config.AddFilterParameterConfiguration("deviceno", "Foo", "@DeviceNo", typeof(System.String));

    • Proposed as answer by Ganeshan Tuesday, July 27, 2010 5:41 PM
    • Marked as answer by M.Bi Wednesday, July 28, 2010 5:57 AM
    Tuesday, July 27, 2010 5:40 PM

All replies

  • You said the machine is an x64 machine. Did you install the 64 bit version of the framework? You can hook VS debugger to the w3wc process and enable "break on all exceptions" to see what error is being raised. Also you can enable tracing (refer the doc file on how) to trace the exceptions. Please reply back with an exception stack so we can help you better.

     


    Maheshwar Jayaraman - http://blogs.msdn.com/mahjayar
    Friday, July 23, 2010 5:12 PM
  • The easiest way to track down service issues is to use set the ISyncServiceConfiguration.UseVerboseErrors property to true in the InitializeService method. Without this setting the server only sends down generic error messages to the client.
    Friday, July 23, 2010 5:15 PM
  • Thank you very much for your answers!

    Setting UseVerboseErrors did the trick. Shame on me that i haven't looked it up in the docs myself. To be honest i didn't expect such a setting because all other errors i had encountered before had been reported explicitly by the service.

    Anyways, here is the server response:

    <ServiceError xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Synchronization.Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ErrorDescription>System.NullReferenceException&#xD;
    Object reference not set to an instance of an object.&#xD;
      at Microsoft.Synchronization.Services.SqlProvider.SqlSyncProviderService.CreateNewScopeForClient()&#xD;
      at Microsoft.Synchronization.Services.SqlProvider.SqlSyncProviderService.GetChanges(Byte[] clientKnowledgeBlob)&#xD;
      at Microsoft.Synchronization.Services.DownloadChangesRequestProcessor.ProcessRequest(Request incomingRequest)&#xD;
      at Microsoft.Synchronization.Services.SyncService`1.ProcessRequestForMessage(Stream messageBody)&#xD;
    &#xD;
    &#xD;
    </ErrorDescription></ServiceError>
    Breaking on all errors didn't help any further:

    System.NullReferenceException occurred
     Message=Object reference not set to an instance of an object.
     Source=Microsoft.Synchronization.Services
     StackTrace:
        at Microsoft.Synchronization.Services.SqlProvider.SqlSyncProviderService.CreateNewScopeForClient()
     InnerException: 
    


    Monday, July 26, 2010 6:35 AM
  • Hi M.Bi.,

    To troubleshoot this further, can you please copy paste the code inside the InitializeService method of the WCF service (.svc.cs) file?

    Monday, July 26, 2010 6:16 PM
  •     public static void InitializeService(Microsoft.Synchronization.Services.ISyncServiceConfiguration config) {
          // TODO: MUST set these values
          config.ServerConnectionString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ToString();
    
          config.SetEnableScope("*");
          config.AddFilterParameterConfiguration("deviceno", "MyTable", "@DeviceNo", typeof(System.String));
    
          config.UseVerboseErrors = true;
    
        }
    
    Tuesday, July 27, 2010 7:06 AM
  • The table MyTable was provisioned with GlobalName="Foo" and the AddFilterParameterConfiguration method must reference it using the global name "Foo" and not the local name "MyTable". Please change the following line and your issue should be fixed.

     config.AddFilterParameterConfiguration("deviceno", "MyTable", "@DeviceNo", typeof(System.String));

    to

     config.AddFilterParameterConfiguration("deviceno", "Foo", "@DeviceNo", typeof(System.String));

    • Proposed as answer by Ganeshan Tuesday, July 27, 2010 5:41 PM
    • Marked as answer by M.Bi Wednesday, July 28, 2010 5:57 AM
    Tuesday, July 27, 2010 5:40 PM
  • Thank you very much for your assistance and your great commitment.
    • Proposed as answer by Bruce Do Wednesday, September 1, 2010 1:27 AM
    Wednesday, July 28, 2010 5:58 AM
  • Hi Ganeshan,

    I am using Syncframework "v4.0 October 2010 CTP" and seem to be getting the same exception "NullReferenceException CreateNewScopeForClient()". There is no indication that the GlobalNames are not correct in my case.

    You can find the config here.

    my Service config params:

    public static void InitializeService(Microsoft.Synchronization.Services.ISyncServiceConfiguration config) {
          // TODO: MUST set these values
          config.ServerConnectionString = ConfigurationManager.ConnectionStrings["ApplicationServices"].ToString();
    
          config.SetEnableScope("DefaultScope");
          config.AddFilterParameterConfiguration("UserId", "PrimaryContact", "@UserId", typeof(System.Guid));
          config.AddFilterParameterConfiguration("UserId", "SecondaryContact", "@UserId", typeof(System.Guid));
          config.AddFilterParameterConfiguration("UserId", "Connection", "@UserId", typeof(System.Guid));
          config.AddFilterParameterConfiguration("UserId", "ContactCategory", "@UserId", typeof(System.Guid));
          config.AddFilterParameterConfiguration("UserId", "ConnectionRequest", "@UserId", typeof(System.Guid));
          config.AddFilterParameterConfiguration("UserId", "ContactRelation", "@UserId", typeof(System.Guid));
          config.AddFilterParameterConfiguration("UserId", "ConnectionSuggestion", "@UserId", typeof(System.Guid));
          config.AddFilterParameterConfiguration("UserId", "Invitation", "@UserId", typeof(System.Guid));
          
          // TODO: Optional.
          config.UseVerboseErrors = true;
          config.EnableDiagnosticPage = true;
    
        }
    

    the fault url:

    POST: /Services/DefaultScopeSyncService.svc/DefaultScope/DownloadChanges?UserId=c032c04d-07ab-445a-935f-bba1414bcf0b

    RESPONSE:

    <ServiceError xmlns="http://schemas.datacontract.org/2004/07/Microsoft.Synchronization.Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ErrorDescription>System.NullReferenceException&#xD;
    Object reference not set to an instance of an object.&#xD;
      at Microsoft.Synchronization.Services.SqlProvider.SqlSyncProviderService.CreateNewScopeForClient()&#xD;
      at Microsoft.Synchronization.Services.SqlProvider.SqlSyncProviderService.GetChanges(Byte[] clientKnowledgeBlob)&#xD;
      at Microsoft.Synchronization.Services.DownloadChangesRequestProcessor.ProcessRequest(Request incomingRequest)&#xD;
      at Microsoft.Synchronization.Services.SyncService`1.ProcessRequestForMessage(Stream messageBody)&#xD;
    &#xD;
    &#xD;
    </ErrorDescription></ServiceError>
    

    Please help! Best regards,

    Constantinos

     

    Friday, February 25, 2011 1:21 PM
  • Hi Constantinos,

    Can you also paste the config file that you used to create the service code?


    SDE, Sync Framework - http://www.giyer.com
    Friday, February 25, 2011 5:00 PM
  • Hi Ganeshan,

    you can find the config int the following link: DefaultSync.config. I could not paste the xml here because off max char limitation to the post :-)

    If it is of any help you can download a backup of the provisioned database here (is a backup from a SQL 2008 R2 instance): DatabaseBackup.bak

    Here is a screenshot of the sync service diagnostics page:

    diagnostics

    Constantinos.

    Friday, February 25, 2011 6:27 PM
  • Hi Constantinos,

    You seem to be missing an config.AddFilterParameterConfiguration call for the Profile table which is also filtered on UserId. Please add it and lets see if it fixes the problem.


    SDE, Sync Framework - http://www.giyer.com
    • Proposed as answer by Indice Monday, February 28, 2011 7:03 PM
    Monday, February 28, 2011 6:21 PM
  • Hi Ganeshan and thank you for your valuable help. You pointed me in the correct direction because the bug you pointed out was one of three problems I had.

    I also had different namespaces in the client and server and the entity "ContactCategory" was a lookup with no filter. Lucky for me the seccond and third errors were easy to find as they throw a meaningfull exception.

    Thanks again for your immediate responce.

    Best regards,

    Constantinos.


    Constantinos Leftheris. http://www.indice.gr
    Monday, February 28, 2011 7:03 PM