Using C# reflection to inspect the metadata of an arbitrary .NET DLL, how do I find out if it is written in .NET core (e.g. .NET 6.0 or 7.0) or .NET Framework (e.g. .NET Framework 4.7.2)?
The reason I ask this question, is that I am creating a user interface application used to load existing .NET DLLs, examine them using reflection, and do something.
I have created two versions of this UI, one in .NET core, one in .NET Framework. I intend to let the .NET Core UI to only open DLLs written in .NET core, and the .NET Framework UI to only open DLLs written in .NET Framework. This way I can avoid unexpected strange exceptions due to incompatibility.
For this to happen, when the user uses the .NET Core version of my app to select a DLL written in .NET Framework, I want the app to raise an error message and refues to proceed. Vice versa. This requires my code to tell what the DLL is written in.