Roy Solberg
Roy Solberg

Reputation: 19723

InvalidCastException when casting to Applicaiton class after Mono upgrade

I just started up my project in MonoDevelop again after not having looked at it for a few months. Of course there was a new version for Mono, MonoDevelop and Mono for Android.

As soon as I run the app I get a InvalidCastException when casting to my Application class in one of my activities:

Error:System.InvalidCastException: Cannot cast from source type to destination type.

The line comes from

ConferenceApplication conferenceApplication = ((ConferenceApplication)base.Application);

When I print the base.Application.Class it reports mono.android.app.Application and not my own application class. My application class is denoted with [Application] and extends Android.App.Application.

I'm pretty confident that the app has not been changed since the last time I ran it. What could the cause for this problem be? And how can I fix it?

I'm using the Beta channel for updates.

MonoDevelop 3.0.4.7
Mono 2.10.9
Mono for Android: 4.2.8

Upvotes: 1

Views: 159

Answers (1)

Roy Solberg
Roy Solberg

Reputation: 19723

I downgraded to latest stable of Mono for Android - 4.2.6 - and it all magically just worked.

Upvotes: 1

Related Questions