I have the need to make a call to the System.Xaml library in .NET 4.0. Is it possible to make a call to this library if your project is targeted to 3.5?
No. You'll need to target your project to run in .NET 4, and to use the CLR v4, in order to use .NET 4 assemblies.
On a different note - there is no real advantage here. Just change your application to target .NET 4. If you are going to add a dependency on the .NET 4 framework assemblies, you might as well just target .NET 4 in the first place...
Here's a kind of Rube Goldberg-esque solution which involves wrapping your .NET 4 DLL methods in COM, and then calling that COM wrapper from .NET 3.5:
https://www.codeproject.com/Articles/204406/How-To-Use-a-NET-Based-DLL-From-NET-Based-Appl
No, you can't the assembly is mapped differently, one thing that you could do but that's a pain is to create a type in memory that reassembles your net 4.0 dll.
You could use CECIL to get IL instructions.
If you don't know IL very much don't even try to do it.
This question is similar to "how can I use a .NET 2 assembly in .NET 1.x application". It is impossible to add the assembly for new CLR as a reference, but like Hamish pointed out, inter process communication may help.
© 2022 - 2024 — McMap. All rights reserved.