Is it wise to call methods of a Net 4.6.1 assembly from an application build with .Net 4.5 via reflection? RRS feed

  • Question

  • Our scenario is as follows:

    We developing 3rd party addons. Our assemblies are loaded and called via reflection from another application build with .Net 4.5.

    We can ensure  that every need runtime (4.6.1 or 4.7) is installed on the machine the application and addon is running on.

    Can we build our assemblies with .Net 4.6.1 (or even 4.7) when the applications runs under .Net 4.5 or is this error prone? 

    Thank you


    Sunday, March 18, 2018 6:50 PM

All replies

  • It's generally a bad idea.

    If the assembly is loaded into a .NET 4.5 environment, then the reflection will fail and you would need to be able to handle that. If you know for certain that the assembly will be loaded into a 4.6.1+ environment, then you should just target the higher version.

    If you decide to do this anyway, you should avoid non-public members/types. things that are not externally visible may change without notice, causing your reflection to break.

    Sunday, March 18, 2018 9:17 PM