PaymillWrapper NuGet package and MVVMCross - System.IO.FileNotFoundException

I faced a question with PaymillWrapper ( https://nuget.org/packages/PaymillWrapper/ ) for Xamarin.Android with MVVMCross.

I installed the latest version 3.3.0.

And added it to my App.cs:

    using MvvmCross.Platform;
    using MvvmCross.Platform.IoC;
    using PaymillWrapper;

    namespace App.Core
    {
        public class App : MvvmCross.Core.ViewModels.MvxApplication
        {
            public override void Initialize()
            {
                CreatableTypes()
                    .EndingWith("Service")
                    .AsInterfaces()
                    .RegisterAsLazySingleton();

                RegisterNavigationServiceAppStart<ViewModels.AppViewModel>();

                PaymillContext paymillContext = new PaymillContext("my-private-token");
            }
        }
    }

After that, I try to call it from my ViewModel:

    using MvvmCross.Core.ViewModels;
    using MvvmCross.Platform;
    using PaymillWrapper;
    using PaymillWrapper.Models;
    using PaymillWrapper.Service;
    using System;
    using System.Windows.Input;

    namespace App.Core.ViewModels
    {
        public class AppViewModel : MvxViewModel
        {
         ...

        PaymentService paymentService = paymillContext.PaymentService;

        public ICommand PayCommand => new MvxCommand(() => {

            Payment payment = paymentService.CreateWithTokenAsync("my-public-token").Result;
        });

But I can see the following error:

I tried to move initialization to ViewModel:

    static PaymillContext paymillContext = new PaymillContext("my-private-token");

    PaymentService paymentService = paymillContext.PaymentService;

    public ICommand PayCommand => new MvxCommand(() => {

        Payment payment = paymentService.CreateWithTokenAsync("my-public-token").Result;
        });

In this case, I don't have underlines but the project doesn't build successfully:

    Error       Exception while loading assemblies: System.IO.FileNotFoundException: 
    Could not load assembly 'PaymillWrapper, Version=0.3.3.0, Culture=neutral, PublicKeyToken='. 
    Perhaps it doesn't exist in the Mono for Android profile?
    File name: 'PaymillWrapper.dll'
       at 
    Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve
    (AssemblyNameReference reference, ReaderParameters parameters)
       at 
    Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences
    (DirectoryAssemblyResolver resolver, ICollection`1 assemblies, 
    AssemblyDefinition assembly, Boolean topLevel)
       at 
    Xamarin.Android.Tasks.ResolveAssemblies.Execute
    (DirectoryAssemblyResolver resolver)    App.Droid           

What am I missing here?

I tried this solution with different versions of MVVMCross (5.2.1, 5.6.0, 5.7.0).

What I have tried else:

  • Clean the solution and delete obj and bin. The same result.
  • Recover my Visual Studio and reinstall packages. The same result.
  • Create a question on StackOverflow. Somebody says that it's unreal because PaymillWrapper doesn't support .NetStandard2.0. But my colleagues successfully use it.
  • Send a question to Paymill support. They didn't answer yet.

Do you have any thoughts about this?

Sign In or Register to comment.