Guid导致格式exception
我正在尝试设置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() .SingleInstance(); builder.Register(x => { var fileStore = new FilesStore() { Url = "https://localhost:40000", DefaultFileSystem = "MyFS", }.Initialize(); return fileStore; }).SingleInstance(); return builder.Build(); } }
在传奇中:
protected override void ConfigureHowToFindSaga(SagaPropertyMapper mapper) { mapper.ConfigureMapping(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( 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:BuildsRavenDB-Stable-3.5Raven.Client.LightweightConvertersGuidConverter.cs:line 51 at Raven.Client.Document.GenerateEntityIdOnTheClient.SetPropertyOrField(Type propertyOrFieldType, Object entity, Action`1 setIdentifier, String id) in C:BuildsRavenDB-Stable-3.5Raven.Client.LightweightDocumentGenerateEntityIdOnTheClient.cs:line 170 at Raven.Client.Document.GenerateEntityIdOnTheClient.TrySetIdentity(Object entity, String id) in C:BuildsRavenDB-Stable-3.5Raven.Client.LightweightDocumentGenerateEntityIdOnTheClient.cs:line 143 at Raven.Client.Document.InMemoryDocumentSessionOperations.d__99.MoveNext() in C:BuildsRavenDB-Stable-3.5Raven.Client.LightweightDocumentInMemoryDocumentSessionOperations.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.d__96.MoveNext() in C:BuildsRavenDB-Stable-3.5Raven.Client.LightweightDocumentInMemoryDocumentSessionOperations.cs:line 803
有帮助吗?
删除后
store.Conventions.IdentityPartsSeparator = "-";
问题是固定的。 请参阅上面的HadiEskandari的评论以及此链接以获取更多信息: RavenDB.SagaPersister.Save中的exception,“Guid应包含32位数,包含4个破折号”。 在Raven,Guid是空的
上述就是C#学习教程:Guid导致格式exception分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1030070.html