Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Forms Dependency Service definition issue

I'm developing and app with Xamarin and I'm trying to follow this guide in order to implement and interface for Xamarin Forms for UWP.

So I wrote in PCL this interface:

namespace MyApp {
public interface ISimplePdfLoader {

    void OpenLocal(string uri);

    void Load(object pdfDoc);
  }
}

and in MyApp.UWP I created a class:

[assembly: Dependency(typeof(SimplePdfLoader))]
namespace MyApp.UWP {
public class SimplePdfLoader : ISimplePdfLoader {

    public async void OpenLocal(string uri) {
        ...

        Load(doc);
    }

    public async void Load(object pdfObj) {
        ...
        }
    }
}
}

But it continues to show the error CS7036 No arguments matching the mandatory formal parameter 'loadHintArgument' of 'DependencyAttribute.DependencyAttribute (string, LoadHint)' were specified MyApp.UWP C:\Users...\workspace\my-app\MyApp\MyApp.UWP\SimplePdfLoader.cs 19 and I can not compile the project.

edit: The error is show underlying the line [assembly: Dependency(typeof(SimplePdfLoader))]

like image 291
Antonello Gatto Avatar asked Nov 25 '25 23:11

Antonello Gatto


1 Answers

Remove the below line from top usings section

using System.Runtime.CompilerServices;

and add the below

using Xamarin.Forms;
like image 100
Abdul Gani Avatar answered Nov 28 '25 14:11

Abdul Gani