3

I am using .NET Core 2.1 to load an assembly calling Assembly.ReflectionOnlyLoadFrom(...) but am getting a System.PlatformNotSupportedException exception. Microsoft documentation seems to indicate that it should work. Has this been implemented? If not, are there any alternatives to get exported types from a .NET 4.7.2 assembly using .NET Core?

Assembly.ReflectionOnlyLoadFrom(fileName)
'Assembly.ReflectionOnlyLoadFrom(fileName)' threw an exception of type 'System.PlatformNotSupportedException'
    Data: {System.Collections.ListDictionaryInternal}
    HResult: -2146233031
    HelpLink: null
    InnerException: null
    Message: "ReflectionOnly loading is not supported on this platform."
    Source: "System.Private.CoreLib"
    StackTrace: "   at System.Reflection.Assembly.ReflectionOnlyLoadFrom(String assemblyFile)"
    TargetSite: {System.Reflection.Assembly ReflectionOnlyLoadFrom(System.String)}
ipinak
  • 5,739
  • 3
  • 23
  • 41
Jarrell
  • 31
  • 1
  • 2
  • 1
    It looks like there's [a known issue](https://github.com/dotnet/dotnet-api-docs/issues/1682) on the documentation GitHub. – Joe Sewell Jan 29 '19 at 18:23
  • According to https://github.com/dotnet/corefxlab/blob/master/docs/specs/typeloader.md you should look at `System.Reflection.TypeLoader`. – Ian Kemp Jan 29 '19 at 18:31
  • @IanKemp And where is that class to be found? Can't access it in .NET Core 3 targets. – Ray Mar 10 '19 at 18:07

1 Answers1

0

As written above, reflection is not supported yet on .net core. You can use the experimental use TypeLoader from the LAB's repo.

If you want to use the experimental NuGets, you need to follow instructions on: https://github.com/dotnet/corefxlab (basically adding the NuGet repo - https://dotnet.myget.org/F/dotnet-corefxlab/) and fetch the System.Reflection.TypeLoader.

Don't expect much support though :)

Alon Fital
  • 31
  • 4