Reputation: 16959
Can you use a .NET 4.0 dll in a 3.5 project?
Upvotes: 30
Views: 18969
Reputation: 1
https://code.msdn.microsoft.com/Using-a-NET-4-Based-DLL-bb141db3/
Use our .NET 4 DLL via COM
using System; using Net4ToNet2Adapter; namespace Net2Assembly { class Program { static void Main(string[] args) { Console.WriteLine("CLR version from EXE: {0}", Environment.Version); Type myClassAdapterType = Type.GetTypeFromProgID("Net4ToNet2Adapter.MyClassAdapter"); object myClassAdapterInstance = Activator.CreateInstance(myClassAdapterType); IMyClassAdapter myClassAdapter = (IMyClassAdapter)myClassAdapterInstance; myClassAdapter.DoNet4Action(); } } }
Upvotes: 0
Reputation: 1038770
No you can't. An assembly compiled against .NET 4.0 can be loaded only by the CLR 4.0. On the other hand the CLR 4.0 can load assemblies compiled against .NET 3.5.
Upvotes: 17
Reputation: 88054
Nope. You can use a .Net 3.5 assembly in a 4.0 project, but not the other way around.
Upvotes: 26