Skip to content
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

Webservice SOAP ASMX downt work in iOS .net MAUI 8.0 #5617

Open
herickfaro opened this issue Jul 30, 2024 · 2 comments
Open

Webservice SOAP ASMX downt work in iOS .net MAUI 8.0 #5617

herickfaro opened this issue Jul 30, 2024 · 2 comments
Labels

Comments

@herickfaro
Copy link

herickfaro commented Jul 30, 2024

Describe the bug
I try to consume a SOAP WebService at App MAUI .net 8.0 on an iOS app the error is "dynamic code generation is not supported on this platform", even with AOT enabled. It works normally on Windows Machine connect to webservice.

Error at line 19 from MauiSoapConsumer/MainPage.xaml.cs
Repro project: https://github.com/markos-jr/MauiSoapConsumer

To Reproduce
Steps to reproduce the behavior:
For iOS:

Create a new .NET MAUI App.
Choose the "iPhone 15 SE iOS 17.4" simulator from the list iOS Simulators targets.
Enable AOT Compilation
Debug the app.
Observe the app launch in the simulator, but the debugger detach and report "dynamic code generation is not supported on this platform"

`
image

@herickfaro herickfaro changed the title Webservice SOAP ASMX downt work in Android and iOS .net MAUI 8.0 Webservice SOAP ASMX downt work in iOS .net MAUI 8.0 Jul 30, 2024
@hwsmo
Copy link

hwsmo commented Aug 1, 2024

Hello, we can also reproduce the error in our iOS app. Our SOAP service no longer works.

@mconnew
Copy link
Member

mconnew commented Aug 22, 2024

Was your app working in earlier versions of .NET MAUI, ie .NET 6, or is this a new app? Line 19 of MauiSoapConsumer/MainPage.xaml.cs isn't where I would have expected an exception like that to appear. We have a couple of places where historically (as in .NET Framework) WCF has used dynamic code generation, but I wouldn't have expected either of those to be hit at that line. The first one we use DispatchProxy to create a class which implements your service interface. I had presumed that had been implemented for aot but it looks like it hasn't been. I think this works for Android as I believe they can support Ref.Emit. The issue tracking this is dotnet/runtime#73136.

The second place is when you use a callback contract. The code which invokes the callback method used to use Ref.Emit on .NET Framework. We've replaced it with 2 implementations. When dynamic code generation is enabled, we use Expression to call it. When it isn't supported, we invoke it using MethodInfo.Invoke.

But you're hitting the aot DispatchProxy lack of support problem. There's not much we can do about that. Xamarin had an interesting approach (it had its own implementation of WCF pulled from mono) where they addressed this in the "Add Service Reference" tooling. They generated a client derived from ClientBase<TChannel> and in the emitted methods, they called another method they created on a WCF type (I forget which one, might have been ServiceChannelProxy) which was passed a string with the method name and an array of parameters. I couldn't find an immediately obvious way to do the same thing in this code base, but I have a couple of potential ideas to try. It's difficult to try things as I don't have a Mac to compile an app on, and I don't have an iPhone to try running it so I might suggest some things to try which may or may not work.

If I don't come back to this within a week, feel free to mention me to give me a nudge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants