hyperledger-archives / aries-framework-dotnet

Aries Framework .NET for building multiplatform SSI services
https://wiki.hyperledger.org/display/aries
Apache License 2.0
84 stars 74 forks source link

System.InvalidOperationException in Xamarin Forms (iOS) #142

Closed sahil-khanna closed 3 years ago

sahil-khanna commented 3 years ago

Describe the bug I have set up a Xamarin Forms app for iOS. In the initial configuration (to register a container, an exception is thrown. Below is the source code. The sample project that I have built is available here

public partial class App : Application
    {
        internal static IContainer Container { get; private set; }

        public App()
        {
            InitializeComponent();

            RegisterContainer();

            MainPage = new MainPage();
        }

        private void RegisterContainer()
        {
            var services = new ServiceCollection();
            services.AddLogging();

            // Initialize Autofac
            var builder = new ContainerBuilder();

            builder.RegisterAssemblyTypes(typeof(IConnectionService).Assembly)
                .AsImplementedInterfaces();
            builder.RegisterType<HttpClient>().AsSelf();

            builder.Populate(services);

            // Build the final container
            Container = builder.Build();    // *** EXCEPTION HERE ***
        }
    }

To Reproduce Steps to reproduce the behavior:

  1. Setup the Xamarin Forms project
  2. Run the app on the simulator
  3. The app crashes at the line Container = builder.Build();

Expected behavior The app should be able to build the Container, just like it does correctly for Android

Screenshots https://drive.google.com/file/d/1aNyNp64g6j9aw0SmtMmJG-PuEHMVFSvr/view?usp=sharing

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context No exception is raised in Android

tmarkovski commented 3 years ago

The app is set to strip all symbols, when no code is using them. You don't need this in Debug mode. You can turn off linking in iOS project options. Set it do "Don't link" or "SDK Only"

image
sahil-khanna commented 3 years ago

Thanks, @tmarkovski. Changing the Link behavior to "Don't link" solved the issue. The agent provisions successfully.

Referring to the code here to create a new invitation, I'm getting the below error

CS1503: Argument 1: cannot convert from 'Hyperledger.Aries.Agents.AgentContext' to 'AgentFramework.Core.Contracts.IAgentContext'

Screenshot here

Can you advise on this, please?

sahil-khanna commented 3 years ago

Thanks, @tmarkovski. Changing the Link behavior to "Don't link" solved the issue. The agent provisions successfully.

Referring to the code here to create a new invitation, I'm getting the below error

CS1503: Argument 1: cannot convert from 'Hyperledger.Aries.Agents.AgentContext' to 'AgentFramework.Core.Contracts.IAgentContext'

Screenshot here

Can you advise on this, please?

This seems to work in the Aries MobileAgent Xamarin