Guid 导致格式异常 [英] Guid is causing a format exception

查看:93
本文介绍了Guid 导致格式异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to set up RavenDb 3.5 and NServiceBus 6. After I senter the saga that I have set up in my NServiceBus endpoint, I enter a handler. Once this handler is finished, I get this error:

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

System.FormatException: Guid should contain 32 digits with 4 dashes (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

有什么帮助吗?

推荐答案

移除后

        store.Conventions.IdentityPartsSeparator = "-";

问题已解决.有关更多信息,请参阅上面 HadiEskandari 的评论和此链接:RavenDB.SagaPersister.Save 中的异常,Guid 应包含 32 位数字和 4 个破折号".Raven 中的 Guid 为空

the issue was fixed. See HadiEskandari's comment above and this link for more info: Exception in RavenDB.SagaPersister.Save, "Guid should contain 32 digits with 4 dashes". Guid is empty in Raven

这篇关于Guid 导致格式异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆