Question

Will it be possible to call a future .net version (let's say .net 5) assembly from .net 4 code by using the c# dynamic keyword?

No correct solution

OTHER TIPS

No.

The dynamic keyword allows late binding of objects. The type still have to be compatible to the .NET runtime where the program runs.

The simple answer is: no.

If you are compiling for .net 4 in MSBUILD, the compiler will not be aware of assemblies in .net 5.

However, you should be able to target .net 5 with MSBUILD, your old code should** compile, and you will also have access to .net 5 assemblies.

As for the dynamic part - I don't believe .net 5 assemblies will be included, as the bin folder assemblies will be for the version of .net you've targeted.

Version Compatibility in the .NET Framework

You have no way of loading the DLL which would still be required to instantiate a variable of that type. dynamic just handles the complexity of runtime binding of the method to be called, it does not provide any features that weren't available before.

Could you try creating a .NET 5 COM binding that you can load between CLR boundaries.

http://www.codeproject.com/Articles/204406/How-To-Use-a-NET-4-Based-DLL-From-NET-2-Based-Appl

However you really should look into whether upgrading to .NET 5 or backporting the .NET 5 code to .NET 4.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top