jeudi 5 avril 2018

Is it possible to load platform specific .net libraries in net core?

My goal is to create a plugin type structure where my net core 2.0 library attempts to load an unknown (until runtime) type by reflecting through libraries in a folder.

Some of these types may require platform specific implementations. I've attempted this by dynamically loading a .net framework 4.6.1 library (which in turn depends on System.Windows.Forms) but when the code attempts to invoke a method on the successfully constructed type I receive the following exception:

Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)

Reading MSDN it suggests that the dependant System.Windows.Forms.dll must be being loaded into the wrong context?

First question, is there something simple I need to change to get this to work?
Secondly, is this sort of thing even possible? (mixing core with platform specific libraries)
Is there a better way to be doing this that I'm unaware of? Google is turning up decidedly limited documentation.





Aucun commentaire:

Enregistrer un commentaire