Guid导致格式异常

时间:2017-08-15 13:50:13

标签: c# ravendb nservicebus

我正在尝试设置RavenDb 3.5和NServiceBus 6.在我输入我在NServiceBus端点中设置的传奇之后,我输入了一个处理程序。完成此处理程序后,我收到此错误:

  

System.FormatException:Guid应该包含32个数字,包含4个破折号(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。

我的代码:

public static class AutoFacConfig
{
    public static IContainer ConfigureAutofac()
    {
        var builder = new ContainerBuilder();

        var resourceManagerId = new Guid("6c9abcbb-c7ca-4a67-a149-5142f633f535");

        var dtcRecoveryBasePath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
        var recoveryPath = Path.Combine(dtcRecoveryBasePath, "NServiceBus.RavenDB", resourceManagerId.ToString());

        builder.Register(x =>
        {
            var store = new DocumentStore
            {
                ConnectionStringName = "RavenDB",
                ResourceManagerId = resourceManagerId,
                TransactionRecoveryStorage = new LocalDirectoryTransactionRecoveryStorage(recoveryPath)
            };
            store.DefaultDatabase = "MyDB";
            store.Initialize();
            store.Conventions.IdentityPartsSeparator = "-";
            return store;
        })
            .As<IDocumentStore>()
            .SingleInstance();

        builder.Register<IFilesStore>(x =>
        {
            var fileStore = new FilesStore()
            {
                Url = "http://localhost:40000",
                DefaultFileSystem = "MyFS",
            }.Initialize();
            return fileStore;
        }).SingleInstance();

        return builder.Build();
    }
}

在传奇中:

    protected override void ConfigureHowToFindSaga(SagaPropertyMapper<FileToOrderSagaData> mapper)
    {
        mapper.ConfigureMapping<StartFileToOrderSagaCommand>(m => m.DataId)
            .ToSaga(s => s.DataId);
    }

    public async Task Handle(StartFileToOrderSagaCommand message, IMessageHandlerContext context)
    {
        // Do Validation ValidateXmlCommand
        Data.DataId = message.DataId;
        await context.Send<ValidateXmlCommand>( x => { x.Filename = message.Filename; x.CustomerId = message.CustomerId; });
    }

这是堆栈跟踪:

at System.Guid.TryParseGuidWithNoStyle(String guidString, GuidResult& result)
at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
at System.Guid..ctor(String g)
at Raven.Client.Converters.GuidConverter.ConvertTo(String value) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Converters\GuidConverter.cs:line 51
at Raven.Client.Document.GenerateEntityIdOnTheClient.SetPropertyOrField(Type propertyOrFieldType, Object entity, Action`1 setIdentifier, String id) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\GenerateEntityIdOnTheClient.cs:line 170
at Raven.Client.Document.GenerateEntityIdOnTheClient.TrySetIdentity(Object entity, String id) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\GenerateEntityIdOnTheClient.cs:line 143
at Raven.Client.Document.InMemoryDocumentSessionOperations.<GenerateDocumentKeyForStorageAsync>d__99.MoveNext() in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:line 833
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Raven.Client.Document.InMemoryDocumentSessionOperations.<StoreAsyncInternal>d__96.MoveNext() in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:line 803

任何帮助人员?

1 个答案:

答案 0 :(得分:1)

删除后

        store.Conventions.IdentityPartsSeparator = "-";

问题已得到解决。 请参阅上面的HadiEskandari的评论和此链接以获取更多信息:Exception in RavenDB.SagaPersister.Save, "Guid should contain 32 digits with 4 dashes". Guid is empty in Raven

相关问题