Forum Cross Platform with Xamarin

MonoTouch does not support dynamic proxy code generation

I'm having an issue with running a cross-platform app on iOS platform.
On Android, it works as intended, but when switching and running it on iOS it does not work.
The errors I am getting are:

MonoTouch does not support dynamic proxy code generation. Override this method or its caller to return specific client proxy instance

 at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel (System.ServiceModel.EndpointAddress address, System.Uri via) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs:141 
  at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel (System.ServiceModel.EndpointAddress address) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs:115 
  at System.ServiceModel.ChannelFactory`1[TChannel].CreateChannel () [0x00006] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/System.ServiceModel/System.ServiceModel/ChannelFactory_1.cs:110 
  at System.ServiceModel.ClientBase`1[TChannel].CreateChannel () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/S
ystem.ServiceModel/System.ServiceModel/ClientBase.cs:266 
  at System.ServiceModel.ClientBase`1[TChannel].get_InnerChannel () [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs:186 
  at System.ServiceModel.ClientBase`1[TChannel].get_Channel () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs:192 
  at ServiceReference1.USD_WebServiceSoapClient.ServiceReference1.USD_WebServiceSoap.login (ServiceReference1.loginRequest request) [0x00001] in [location] 
  at ServiceReference1.USD_WebServiceSoapClient.login (System.String username, System.String password) [0x00015] in [location] 
  at Login.Models.Query.sidAdmin () [0x00001] in [location] 
  at Login.Views.LoginPage.<Btn_Login_Clicked>b__2_0 () [0x0002c] in [location] 
The thread 0xa has exited with code 0 (0x0).

Answers

  • ColeXColeX Member, Xamarin Team Xamurai

    The error comes from the method ServiceReference1.USD_WebServiceSoapClient.ServiceReference1.USD_WebServiceSoap.login , if you can access the code , please check the following points :

    • The System.Reflection.Emit is not available.
    • No support for System.Runtime.Remoting.
    • No support for creating types dynamically (no Type.GetType ("MyType`1")), although looking up existing types (Type.GetType ("System.String") for example, works just fine).
    • Reverse callbacks must be registered with the runtime at compile time.

    If your code meet the condition above , try to modify it or replace with another library to login.

    Refer https://docs.microsoft.com/en-us/xamarin/ios/internals/limitations#no-dynamic-code-generation .

  • SrbaSrba Member ✭✭

    When I tried to create a new project I got the MonoTouch error at

    return base.Channel.login(request)

    I have searched the web for the solution but everyone is saying to override "Channel" class or "ChannelFactory"
    but I have no clue what or where to do it.
    Some other articles said to try importing with Silverlight and slsvcutil but I have no clue what they are or how they are used...

    Snippets of code for Channel and ChannelFactory:

    public class ChannelFactory<TChannel> : ChannelFactory, IChannelFactory, ICommunicationObject, IChannelFactory<TChannel>
        {
            public ChannelFactory(string endpointConfigurationName);
            public ChannelFactory(Binding binding, EndpointAddress remoteAddress);
            public ChannelFactory(string endpointConfigurationName, EndpointAddress remoteAddress);
            protected ChannelFactory(Type channelType);
    
            public TChannel CreateChannel();
            public TChannel CreateChannel(EndpointAddress address);
            public virtual TChannel CreateChannel(EndpointAddress address, Uri via);
            protected override ServiceEndpoint CreateDescription();
        }
    
    public abstract class ClientBase<TChannel> : ICommunicationObject where TChannel : class
        {
            protected ClientBase();
            protected ClientBase(string endpointConfigurationName);
            protected ClientBase(Binding binding, EndpointAddress remoteAddress);
            protected ClientBase(string endpointConfigurationName, EndpointAddress remoteAddress);
            protected ClientBase(string endpointConfigurationName, string remoteAddress);
    
            public CommunicationState State { get; }
            public IClientChannel InnerChannel { get; }
            public ServiceEndpoint Endpoint { get; }
            public ClientCredentials ClientCredentials { get; }
            public ChannelFactory<TChannel> ChannelFactory { get; }
            protected TChannel Channel { get; }
    
            public void Abort();
            protected virtual TChannel CreateChannel();
            protected T GetDefaultValueForInitialization<T>();
            protected void InvokeAsync(BeginOperationDelegate beginOperationDelegate, object[] inValues, EndOperationDelegate endOperationDelegate, SendOrPostCallback operationCompletedCallback, object userState);
    
            protected class ChannelBase<T> : IDisposable, IChannel, ICommunicationObject, IOutputChannel, IRequestChannel, IClientChannel, IContextChannel, IExtensibleObject<IContextChannel> where T : class
            {
                protected ChannelBase(ClientBase<T> client);
    
                [SecuritySafeCritical]
                protected IAsyncResult BeginInvoke(string methodName, object[] args, AsyncCallback callback, object state);
                [SecuritySafeCritical]
                protected object EndInvoke(string methodName, object[] args, IAsyncResult result);
            }
            protected class InvokeAsyncCompletedEventArgs : AsyncCompletedEventArgs
            {
                public object[] Results { get; }
            }
    
            protected delegate IAsyncResult BeginOperationDelegate(object[] inValues, AsyncCallback asyncCallback, object state);
            protected delegate object[] EndOperationDelegate(IAsyncResult result);
        }
    
Sign In or Register to comment.