2017-08-15 229 views
1

我正在嘗試設置RavenDb 3.5和NServiceBus 6.在我發出了我在NServiceBus端點中設置的傳奇後,我輸入了一個處理程序。一旦這個處理程序完成後,我得到這個錯誤:Guid導致格式異常

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 

任何幫助球員?

+4

您的代碼中哪裏出現錯誤? – Magnus

+1

似乎是一個RavenDB問題,你認爲這是相關的,因爲你在代碼中使用'IdentityPartsSeparator':https://stackoverflow.com/questions/26787884/exception-in-ravendb-sagapersister-save-guid-should -contain-32-digits-with-4-d –

+0

@HadiEskandari它是相關的,它解決了我的問題。謝謝哈迪! :) –

回答