How to make Visual Studio see .NetStandard dependencies from shared project

I have successfully converted existing PCL project (which uses couple of third-party libraries such as Autofac) with shared code to the .NetStandard 1.3.

Unfortunately application build fails now with the following message:

Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Autofac, Version=, Culture=neutral, PublicKeyToken=17863af14b0044da'. Perhaps it doesn't exist in the Mono for Android profile?

Why is that and how to fix it? I don't really want to add the same packages (Autofac, etc) to the application project as it doesn't use them directly.


  • MikhailMelnikMikhailMelnik AUMember ✭✭

    Have anyone had an experience with migration of PCL libraries to the .NetStandard? What is the general approach?

  • PerHungebergMllerPerHungebergMller DKMember ✭✭✭

    @MikhailMelnik I have the exact same problem with Autofac after converting my PCL project to .NET Standard.

    Did you solve your problem?

    Does anyone have a solution for this?

    I tried downgrading Autofac to version 3.5.2 that does not depend on .NET Standard I think, but the build error is this there.

  • PerHungebergMllerPerHungebergMller DKMember ✭✭✭

    @MikhailMelnik Just for reference, I figured it out.

    It turns out that Autofac 4.x has some platform specifics that need to be included in every platform project for the projects to compile when using Autofac in a portable (.NET standard) project.

    So the fix is simply to add same Autofac nuget version to all the platform specific projects (iOS, Android, UWP etc.) and rebuild.

    By doing that I also found out that there are other libraries like Newtonsoft.Json that has platform specifics and need the same fix.

    This has to be done even thou you do not use anything from the libraries in your platform specific code yourself.

Sign In or Register to comment.