Skip to content

Conversation

@grendello
Copy link
Contributor

…public

Fixes: #10602
Context: 8bc7a3e

This is in the category of "how the hell has it worked before?", as every time the AndroidEnvironmentInternal.UnhandledException method living in Mono.Android.Runtime.dll would be called, the runtime would respond with a method not accessible exception, rightly so as both the type and the method were internal and visible only to Mono.Android.dll.

I guess we haven't had many unhandled exceptions in marshal method wrappers over the years?

This PR fixes the problem by making both the type and the method public. This is the simplest way to fix the issue.

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we write some Mono.Cecil code to make this public at build time? So, no one can use it at C# compile time?

This would happen in the marshal methods MSBuild steps, if they run.

@grendello grendello marked this pull request as draft November 24, 2025 15:00
…public

Fixes: #10602
Context: 8bc7a3e

This is in the category of "how the hell has it worked before?", as every time the
`AndroidEnvironmentInternal.UnhandledException` method living in `Mono.Android.Runtime.dll`
would be called, the runtime would respond with a method not accessible exception, rightly
so as both the type and the method were internal and visible only to `Mono.Android.dll`.

I guess we haven't had many unhandled exceptions in marshal method wrappers over the years?

This PR fixes the problem by making both the type and the method public. This is the simplest
way to fix the issue.
The rewrite changes visibility of the `Android.Runtime.AndroidEnvironmentInternal` type
from `internal` to `public` after all the linking and marshal method processing is done.
@grendello grendello force-pushed the dev/grendel/mm-unhandledexception branch from a2771cd to 826cf5b Compare November 25, 2025 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crashes with Method Android.Runtime.AndroidEnvironmentInternal.UnhandledException(System.Exception) is inaccessible (...) exception

3 participants