question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cosmos DB Throws "Unable to cast object of type 'System.Int64' to type 'System.Int32'" when Calling ContinueDialogAsync

See original GitHub issue

Github issues should be used for bugs and feature requests. Use Stack Overflow for general “how-to” questions.

Version

Microsoft.Bot.Builder v4.4.0

Describe the bug

When executing line

await dialogContext.ContinueDialogAsync(cancellationToken)

System.InvalidCastException is thrown with details “Unable to cast object of type ‘System.Int64’ to type ‘System.Int32’”

To Reproduce

Steps to reproduce the behavior: Using CosmosDB storage Execute the first message, works fine Upon the second message, calling ContinueDialogAsync(…) fails

Expected behavior

Give a clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

Using MemoryStorage does not have this problem Works fine in version 4.3.0

[bug]

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
sgellockcommented, May 3, 2019

we’re cutting a 4.4.1 release of the C# SDK to address this issue.

1reaction
EricDahlvangcommented, May 3, 2019

https://github.com/Microsoft/botbuilder-dotnet/blob/master/libraries/Microsoft.Bot.Builder.Dialogs/WaterfallDialog.cs#L112

        // For issue https://github.com/Microsoft/botbuilder-dotnet/issues/871
        // See the linked issue for details. This issue was happening when using the CosmosDB
        // data store for state. The stepIndex which was an object being cast to an Int64
        // after deserialization was throwing an exception for not being Int32 datatype.
        // This change ensures the correct datatype conversion has been done.
        var index = Convert.ToInt32(state[StepIndex]);
Read more comments on GitHub >

github_iconTop Results From Across the Web

.net - C#: Unable to cast object of type 'System.Int64' ...
When I convert the Color to an int, I get the following exception: System.InvalidCastException: Unable to cast object of type 'System.Int64' to ...
Read more >
System.InvalidCastException: Unable to cast object of type ...
HI, I received this message : System.InvalidCastException: Unable to cast object of type 'System.Int64' to type 'System.Int32'.
Read more >
[Solved] C# Error: Unable to cast object of type 'System.Int64 ...
This error mostly accure due to SQL bigint is the equivalent to .NET long, GetInt64 returns a long, while GetInt32 returns an int....
Read more >
Troubleshoot an application using the Azure Cosmos DB ...
The first thing to notice in this new code, is that on the catch we're capturing an exception of type CosmosException class. This...
Read more >
Getting Started with the Microsoft Azure Cosmos Database ...
Microsoft Azure Cosmos DB operation - The operation represents an action against a specific record type. You can create one or more operations, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found