-
Notifications
You must be signed in to change notification settings - Fork 517
Incompatibilities between CoreCLR and Mono
Rolf Bjarne Kvinge edited this page May 10, 2022
·
1 revision
Mono accepts both +
and /
as the character that separates the declaring type and the nested type, while CoreCLR only accepts /
.
Example:
using System;
class Program
{
class N {}
static void Main (string[] args)
{
Console.WriteLine ($"Program+N: {typeof (Program).Assembly.GetType ("Program+N")}");
Console.WriteLine ($"Program/N: {typeof (Program).Assembly.GetType ("Program/N")}");
}
}
Mono prints:
$ mcs Program.cs && mono Program.exe
Program+N: Program+N
Program/N: Program+N
CoreCLR prints:
$ dotnet run
Program+N: Program+N
Program/N:
It's not possible to pass an Action<T>
or a Func<T>
to a P/Invoke or Marshal.GetFunctionPointerForDelegate.
Example:
using System;
using System.Runtime.InteropServices;
class App {
public static void Main ()
{
Action<int> a = v => {};
var p = Marshal.GetFunctionPointerForDelegate (a);
Console.WriteLine (p);
}
}
Mono prints:
$ mcs Program.cs && mono Program.exe
4500559232
CoreCLR prints:
$ dotnet run
Unhandled exception. System.ArgumentException: The specified Type must not be a generic type. (Parameter 'delegate')
at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegateInternal(Delegate d)
at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(Delegate d)
at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate[TDelegate](TDelegate d)
at App.Main() in Program.cs:line 8
Ref: https://github.com/dotnet/runtime/issues/32963
This means that no entry point into managed code can "leak" exceptions back into native code, because CoreCLR will abort the process.
For Objective-C entry points, Xamarin will catch managed exceptions and convert them to Objective-C exceptions, but this won't be done for reverse P/Invokes in user code.
As a result, the UnwindNativeCode
and UnwindManagedCode
values for exception marshaling are not valid when using CoreCLR.
- README
- xcode13.0 Binding Status
- xcode13.1 Binding Status
- xcode13.2 Binding Status
- xcode13.3 Binding Status
- xcode13.4 Binding Status
- xcode14.0 Binding Status
- xcode14.1 Binding Status
- xcode14.2 Binding Status
- xcode14.3 Binding Status
- xcode15.0 Binding Status
- xcode15.1 Binding Status
- xcode15.3 Binding Status
- xcode15.4 Binding Status
- xcode16.0 Binding Status
- xcode16.1 Binding Status
- xcode16.2 Binding Status