-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] Throws runtime error in mscorlib
, expected class System.Runtime.CompilerServices.ValueTaskAwaiter1
#82193
Comments
System.Threading.Channels
throws error in mscorlibSystem.Threading.Channels
throws runtime error in mscorlib
System.Threading.Channels
throws runtime error in mscorlibSystem.Threading.Channels
throws runtime error in mscorlib, expected class System.Runtime.CompilerServices.ValueTaskAwaiter1
System.Threading.Channels
throws runtime error in mscorlib, expected class System.Runtime.CompilerServices.ValueTaskAwaiter1
System.Runtime.CompilerServices.ValueTaskAwaiter1
System.Runtime.CompilerServices.ValueTaskAwaiter1
mscorlib
, expected class System.Runtime.CompilerServices.ValueTaskAwaiter1
mscorlib
, expected class System.Runtime.CompilerServices.ValueTaskAwaiter1
mscorlib
, expected class System.Runtime.CompilerServices.ValueTaskAwaiter1
I can use System.threading.channel as you said, you should reach out to ably too meanwhile check if trimming is what's breaking this if is then you can also have guys at roslyn or ASP.NET take a look for you |
I am the person from ably responsible for maintaining the |
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
@rachelkang I am not sure why this issue was transferred to |
Any update on this @Redth and @XamlTest ? CC @rachelkang |
The problem is very likely down to this dependency @steveisok could you check why it's failing? |
@marek-safar can you try this app ->https://github.com/sac-fork/MauiAppAblyDemo? If you have a workaround to get this working, it will be super useful 🥇 |
@sacOO7 the short answer is that you need to add a Long answer: .NET (Core) provides a compatibility mechanism for using assemblies which were compiled against the legacy .NET Framework assembly layout (e.g. mscorlib.dll, System.dll etc). The way this works is that we ship a tiny shim mscorlib.dll which is only used to forward the types to their new locations in a different assembly on modern .NET (e.g. System.Private.CoreLib.dll). However this breaks down in this case since the classic Xamarin.Android frameworks used the classic Mono implementation of .NET Framework and we made a few additions that didn't exist in the original Microsoft .NET Framework implementation, mainly to support .NET Standard 2.1 use cases. Your nuget package contains these target frameworks: The A quick way to hack it is to go into your local nuget package cache folder But the real solution is to add a proper |
@akoeplinger Thanks for the answer! I had one final question. |
Also, I feel the project should throw a proper error/ warning if the |
See the legend at the bottom of the table, that target is "computed", because we have this compatibility layer so We can't throw an error since this is supposed to work, you're just hitting an edge case where it doesn't. The compatibility layer is best effort which is why we're recommending adding a real |
Got it @akoeplinger. I had few small questions coming up.
|
No, the only option I can think of would be to remove the
That depends on how your nuget package build works today. You'd need to build with the modern .NET SDK and set |
Great, we will fix this as per your suggestion and will let you know if anything comes up !!! Thanks again, this is really helpful : ) |
I think being able to choose the selection would be useful. At the same time, it will be great to enforce users to make them add explicit targets for |
…b.dll The legacy Xamarin.Android version of mscorlib.dll differed a bit compared to the .NET Framework mscorlib.dll, mostly because of additions for .NET Standard 2.1 support. This meant that an assembly which was compiled against that mscorlib expects types there but since we didn't have type-forwarders in our mscorlib.dll shim to point them to the right assembly you'd get a TypeLoadException when running on modern .NET 6 Android. Fixes dotnet#82193 Should also fix dotnet/maui#5142, dotnet/maui#5078, dotnet/maui#3903
I've also just experimented with adding these missing type forwarders to the mscorlib.dll shim and it fixes the issue as well, i.e. the I opened a PR, we'll see if we can maybe backport it to 7.0: #82618 |
@akoeplinger wow, this is amazing : ) When can we expect this to get merged and available after release? |
…b.dll (#82618) The legacy Xamarin.Android version of mscorlib.dll differed a bit compared to the .NET Framework mscorlib.dll, mostly because of additions for .NET Standard 2.1 support. This meant that an assembly which was compiled against that mscorlib expects types there but since we didn't have type-forwarders in our mscorlib.dll shim to point them to the right assembly you'd get a TypeLoadException when running on modern .NET 6 Android. Fixes #82193
…b.dll (dotnet#82618) The legacy Xamarin.Android version of mscorlib.dll differed a bit compared to the .NET Framework mscorlib.dll, mostly because of additions for .NET Standard 2.1 support. This meant that an assembly which was compiled against that mscorlib expects types there but since we didn't have type-forwarders in our mscorlib.dll shim to point them to the right assembly you'd get a TypeLoadException when running on modern .NET 6 Android. Fixes dotnet#82193 (cherry picked from commit d8203e7)
…ity to mscorlib.dll and System.Drawing.Common.dll (#83137) * Add more type-forwarders for Xamarin.Android compatibility to mscorlib.dll (#82618) The legacy Xamarin.Android version of mscorlib.dll differed a bit compared to the .NET Framework mscorlib.dll, mostly because of additions for .NET Standard 2.1 support. This meant that an assembly which was compiled against that mscorlib expects types there but since we didn't have type-forwarders in our mscorlib.dll shim to point them to the right assembly you'd get a TypeLoadException when running on modern .NET 6 Android. Fixes #82193 (cherry picked from commit d8203e7) * Add type-forwarders for Xamarin.Android compatibility to System.Drawing.Common.dll (#82839) The legacy Xamarin.Android version of System.Drawing.Common.dll contained these types, add forwarders so we don't get a TypeLoadException when using an assembly compiled against that in modern .NET Android. Fixes #82829 (cherry picked from commit e486f38) * Use 7.0 version of the ApiCompat suppressions * Fix diff --------- Co-authored-by: Carlos Sánchez López <1175054+carlossanlop@users.noreply.github.com>
@sacOO7 we merged the backport to the release/7.0 branch and is currently targeted for the 7.0.5 release. |
Thanks @akoeplinger, this is helpful 👍 |
Description
I am unable to use ably package with a dependency on
System.Threading.Channels
(the error might also have origin fromSystem.Threading.Tasks.Extensions
/System.Runtime.CompilerServices.Unsafe
assembly) , throws below runtime exception on MAUI android.Throws a runtime error while trying to run on android =>
It works on a regular net6.0 library, MAUI windows machine, and the latest Xamarin Forms.
I tried all options to disable assembly trimming as per
https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?pivots=dotnet-6-0
but the issue still persists and the app throws an error at runtime.
I strongly feel the issue is related to a missing type in
mscorlib
same as the one mentioned in dotnet/maui#5078 and dotnet/maui#5142Steps to Reproduce
Click me
button, it will throw above error.Link to public reproduction project repository
https://github.com/sac-fork/MauiAppAblyDemo
Version with bug
6.0 / 7.0
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android API 13 to 33
Did you find any workaround?
No workarounds were found.
Relevant log output
The text was updated successfully, but these errors were encountered: