0

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 msg.

System.ArgumentException: Could not convert identity to type System.Guid because there is not matching type converter registered in the conventions' IdentityTypeConvertors

My code:

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 = "-";
            var _guidTypeConvertor = store.Conventions
                .IdentityTypeConvertors
                .FirstOrDefault(id => id.CanConvertFrom(typeof(Guid)));
            if (_guidTypeConvertor != null)
                store.Conventions.IdentityTypeConvertors.Remove(_guidTypeConvertor);
            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();
    }
}

In the saga:

    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; });
    }

Here's the stack trace:

System.ArgumentException: Could not convert identity to type System.Guid because there is not matching type converter registered in the conventions' IdentityTypeConvertors
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 167
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
--- 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 NServiceBus.Persistence.RavenDB.SagaPersister.<Save>d__0.MoveNext() in C:\BuildAgent\work\c4d62ce02b983878\src\NServiceBus.RavenDB\SagaPersister\SagaPersister.cs:line 24
--- 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 NServiceBus.SagaPersistenceBehavior.<Invoke>d__1.MoveNext() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Sagas\SagaPersistenceBehavior.cs:line 133
--- 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 NServiceBus.LoadHandlersConnector.<Invoke>d__1.MoveNext() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\Incoming\LoadHandlersConnector.cs:line 40
--- 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 NServiceBus.InvokeSagaNotFoundBehavior.<Invoke>d__0.MoveNext() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Sagas\InvokeSagaNotFoundBehavior.cs:line 16
--- 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 NServiceBus.DeserializeLogicalMessagesConnector.<Invoke>d__1.MoveNext() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\Incoming\DeserializeLogicalMessagesConnector.cs:line 31
--- 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 NServiceBus.Persistence.RavenDB.OpenAsyncSessionBehavior.<Invoke>d__1.MoveNext() in C:\BuildAgent\work\c4d62ce02b983878\src\NServiceBus.RavenDB\SessionManagement\OpenAsyncSessionBehavior.cs:line 21
--- 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 NServiceBus.InvokeAuditPipelineBehavior.<Invoke>d__1.MoveNext() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Audit\InvokeAuditPipelineBehavior.cs:line 18
--- 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 NServiceBus.SubscriptionReceiverBehavior.<Invoke>d__1.MoveNext() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Routing\MessageDrivenSubscriptions\SubscriptionReceiverBehavior.cs:line 29
--- 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 NServiceBus.ProcessingStatisticsBehavior.<Invoke>d__0.MoveNext() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Performance\Statistics\ProcessingStatisticsBehavior.cs:line 27
--- 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 NServiceBus.ReceivePerformanceDiagnosticsBehavior.<Invoke>d__2.MoveNext() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Performance\Statistics\ReceivePerformanceDiagnosticsBehavior.cs:line 40
--- 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 NServiceBus.TransportReceiveToPhysicalMessageProcessingConnector.<Invoke>d__1.MoveNext() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\Incoming\TransportReceiveToPhysicalMessageProcessingConnector.cs:line 37
--- 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 NServiceBus.MainPipelineExecutor.<Invoke>d__1.MoveNext() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\MainPipelineExecutor.cs:line 32
--- 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 NServiceBus.ReceiveStrategy.<TryProcessMessage>d__7.MoveNext() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Transports\Msmq\ReceiveStrategy.cs:line 109
--- 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 NServiceBus.TransactionScopeStrategy.<ProcessMessage>d__2.MoveNext() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Transports\Msmq\TransactionScopeStrategy.cs:line 86

Searched all over to find out abt this, but I've got no clue as to what this Guid and converter thingy is.

Any help guys? Thx

Travis Illig
  • 23,195
  • 2
  • 62
  • 85
solid_luffy
  • 361
  • 2
  • 15
  • 2
    you should show us some code perhaps. Or didn't you write any code? @ankit_sharma mother of stack trace? :D – Matthias Burger Aug 15 '17 at 13:09
  • True! Added some code – solid_luffy Aug 15 '17 at 13:14
  • 3
    What does this line do `store.Conventions.IdentityTypeConvertors.Remove(_guidTypeConvertor);`? – mjwills Aug 15 '17 at 13:17
  • 1
    It looks like you remove a Guid converter and then you get errors about not having a Guid converter. Maybe try not removing it? – juharr Aug 15 '17 at 13:24
  • I removed the `store.Conventions.IdentityTypeConvertors.Remove(_guidTypeCon‌​vertor);´ and now I'm getting System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). When my guid looked like: cea83a7c-5466-4a07-bece-cc5588e0765f. I'm using Guid.NewGuid() to create Guids. – solid_luffy Aug 15 '17 at 13:30
  • 2
    @solid_luffy that is a new question then. This question is about the guid conversion. please ask in a new question. – tom redfern Aug 15 '17 at 13:37
  • https://stackoverflow.com/questions/45694283/guid-giving-me-format-exception – solid_luffy Aug 15 '17 at 13:51

1 Answers1

0
store.Conventions.IdentityTypeConvertors.Remove(_guidTypeCon‌​vertor);

is removing the Guid Type Convertor. This is why you are experiencing:

System.ArgumentException: Could not convert identity to type System.Guid because there is not matching type converter registered in the conventions' IdentityTypeConvertors

You should remove that line of code.

mjwills
  • 23,389
  • 6
  • 40
  • 63