We have an application written in .NET which browses .NET assemblies using Reflection API. When we use this application to browse dll
compiled with .NET Core 2.0, it fails with following exception. Any help regarding this will be appreciated.
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at ConsoleApp1.Program.NewMethod() in c:\Users\faisal_iqbal\documents\visual studio 2017\Projects\CoreX\ConsoleApp1\Program.cs:line 23
at ConsoleApp1.Program.Main(String[] args) in c:\Users\faisal_iqbal\documents\visual studio 2017\Projects\CoreX\ConsoleApp1\Program.cs:line 16
Answering my own question.
NETCore is a very different framework. If you build that assembly by targeting .NETStandard 2.0 instead and target your app to at least 4.6.1 then you can do this.
– Hans Passant
Since both .NET Framework and .NET Core are different frameworks, each has its own Reflection API
.
If you need to load assemblies merely for meta data reading purpose, use Mono.Cecil framework which works for both .NET Framework as well as for .NET Core. It doesn't load the assembly or dependent assemblies as Reflection does. It simply reads the meta data information like
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With