1

I'm trying to create a custom AssemblyLoadContext utilizing an AssemblyDependencyResolver in C# under Net Core 3.1 (Visual Studio 2019).

But while I can see AssemblyDependencyResolver as a public sealed class in the Object Browser, neither IntelliSense nor the source code editor will admit it exists (and I have a using System.Runtime.Loader statement in the file so it should be recognized).

I've never seen something like this. How do I go about creating an instance of AssemblyDependencyResolver?

Mark Olbert
  • 6,584
  • 9
  • 35
  • 69
  • I made a brand new ConsoleApp targeting netcoreapp3.1 using VS 2019, and was able to get IntelliSense to see `AssemblyDependencyResolver` just fine (also with `using System.Runtime.Loader`). I guess it's time to challenge assumptions: is your project truly targeting .NET Core 3.1? Could it be targeting something else, say netstandard2.1? Have you turned it off and back on again? :P – Sean Skelly Apr 02 '20 at 01:00
  • Right you are -- the project targets NetStandard2.1, which AssemblyLoadContext supports. But AssemblyDependencyResolver only targets Net Core 3 and 3.1. I was confused by an example in the Microsoft docs. Thanx! If you'll write it up as an answer I'll be happy to accept it and upvote it. – Mark Olbert Apr 02 '20 at 02:49
  • No problem - glad it could help, and thanks. – Sean Skelly Apr 02 '20 at 03:06

1 Answers1

2

Per the comment in the question:

Targeting netstandard2.1 will not allow you to access the System.Runtime.Loader.AssemblyDependencyResolver class; only targeting netcoreapp3.0 or netcoreapp3.1 will do that.

Sean Skelly
  • 1,229
  • 7
  • 13