Paymill NuGet package for MVVMCross: Exception while loading assemblies:

53 Views Asked by At

I faced a question with 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: enter image description here

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).

0

There are 0 best solutions below