locked
Trouble with Data Types in FieldSchema during InitializeReplicaMetadata RRS feed

  • Question

  • Using the Managed Code Microsoft Synchronication Framework, when trying to create custom field definitions using FieldSchema in the InitializaeReplicaMetadata method of SqlCeMetadataStore, I am puzzled by the exception that "data type is not supported" for any "type" I have tried to pass in.

     

    System.NotSupportedException : The data type is not supported.

    at

    at Microsoft.Synchronization.MetadataStorage.Utility.ConvertDataTypeToSyncMetadataFieldType(Type dataType)

    at

    at Microsoft.Synchronization.MetadataStorage.SqlCeMetadataStore.CreateCustomFieldDefinition(FieldSchema fieldSchema, String parameterName)

    at

    at Microsoft.Synchronization.MetadataStorage.SqlCeMetadataStore.InitializeReplicaMetadata(SyncIdFormatGroup idFormats, SyncId replicaId, IEnumerable`1 customItemFieldSchemas)

     

    The code generating the exception is:

     

    List<FieldSchema> customItemFieldSchemas = new List<FieldSchema>();

    FieldSchema fieldSchema = new FieldSchema("PointEditDate", typeof(int), false);

    customItemFieldSchemas.Add(fieldSchema);

    replicaMetadata = dataStore.InitializeReplicaMetadata(idFormats, replicaId, customItemFieldSchemas);

     

    When I make the InitializeReplicaMetadata call passing and emtpy custom schemas collection or null then everything works fine. Any idea?

    • Moved by Max Wang_1983 Thursday, April 21, 2011 10:16 PM forum consolidation (From:SyncFx - Technical Discussion [ReadOnly])
    Wednesday, February 6, 2008 8:07 PM

Answers

  • For anyone interested, I will anwser my own question.

     

    There are two "issues". First, it turns out that there are a very limited number of data types supported when creating and using custom FieldSchema. These available types seem to be byte, byte[], Guid, string, uint, ulong and ushort. Second, when specifying a variable length type, ie. string and byte[], the second overload of InitializeReplicaMetadata is required in which a forth argument, maxLength, is required.

     

    When using a supported type with the correct overload of InitializeReplicaMetadata, life is good.

    Wednesday, February 13, 2008 12:58 AM