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.

"System.InvalidCastException: Specified cast is not valid." during Android RestoreInstanceState

See original GitHub issue

🐛 Bug Report

Reproduction steps

  1. Start an Android app with MvvmCross.
  2. Use any app to fill all of the RAM.
  3. Return to the App with MvvmCross.
  4. Get a crash by calling MvxFragment`1.get_ViewModel()
System.InvalidCastException: Specified cast is not valid.
MvvmCross.Platforms.Android.Views.Fragments.MvxFragment`1.get_ViewModel()

An explicit cast to cause the exception

I’ve figured out the type of ViewModel via DataContext in non generic MvxFragment. DataContext’s type is MvxNullViewModel

Expected behavior

No crash. ViewModel’s type is TViewModel of generic MvxFragment<TViewModel>

Configuration

Version: 9.0.9

Platform:

  • 🤖 Android

Issue Analytics

  • State:closed
  • Created 5 months ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
Cheesebaroncommented, May 4, 2023

I’ll see if I can get it done today or tomorrow

0reactions
Cheesebaroncommented, Jul 17, 2023

This was already released. Closing as I guess it is fixed in #4546.

Comment here if I need to reopen.

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.InvalidCastException: Specified cast is not valid. ...
I am on a C# ASP.NET project. I have a MySQL table with a userid field of type int . Now I want...
Read more >
System.InvalidCastException : Specified cast is not valid
I connected a real Android phone to my Mac and recorded a test for it using Appium Studio. I took the code that...
Read more >
System.InvalidCastException: Specified cast is not valid. ...
Hello. I use this design to upload images from the archive. But I ran into the problem, if there are more than 2...
Read more >
MvvmCross/CHANGELOG.md at develop
InvalidCastException : Specified cast is not valid." during Android RestoreInstanceState #4600 ... Cancelable is 'false' when using empty ctor.
Read more >
SQL SERVER - Restore Error: Specified cast is not valid ...
I have a backup from database in SQL Server 2008 R2. When I want to restore this backup to SQL Server, I get...
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