DependencyService in NuGet library

TerryWestleyTerryWestley USUniversity ✭✭

Can a NuGet library use DependencyService?

I have an interface, implementation, and call to DependencyService.Get that used to work before I refactored the interface and implementation out to a NuGet library. The call to DependencyService.Get in the PCL of the application solution always returns null. This is in the context of attempting to use the Bait and Switch PCL trick for a single interface and implementation class.

I can find examples of using DependencyService in Xamarin plugins only in test code, not the library, so I'm beginning to wonder if I missed something about DependencyService.

If the general answer is yes, then there's something wrong in my implementation and I'll post the code here hoping that someone can spot my mistake.

Sign In or Register to comment.