I taught myself coding, and I'm not sure if this is possible. Neither do i know if what I ask here goes by some name (e.g.: "What you ask is called xxxxxx"). I couldn't find anything on this topic (but did find some upgrade articles, which is not exactly what I want, so please excuse me if this sounds like a NOOB question to hardcore coders; I'm a beginner).
I had a small project that relied on .NET 2.0 because of inclusion of some external libraries. The software worked well, but now it needs added functionality; things that would be much more easy to program under .NET 4.0 or 4.5.
However, that included external library isn't at that .NET level, so now I wonder: can a project have multiple .NET versions ?
I'm not sure but was thinking also perhaps I only write my new function as a dll that depends on .NET 4.5, in which I write my public functions in a different project, then later include that final dll in my prj that depends on .NET 2.0... not sure if this would be the way to go though.
Yes, you can include .NET 2 assemblies into a .NET 4 or .NET 4.5 project (or any version if you will). Including a .NET 4 assembly in a .NET 2 project won't work.
If you want to use new features in a base project, you need to upgrade all projects that rely on it. Make sure that the entire tree supports .NET 4 then (for example Office add-ins, or other related software you might use).
An exception is the use of mixed-mode assemblies (assemblies that use both .NET and unmanaged code), which are more tight to the CLR and they might cause problems due to the activity policy (MSDN).
You can only use one .NET version, and that's the version that your primary application requires (or is configured) to use. However, .NET is largely backwards compatible with older versions and can often run older assemblies unchanged in newer versions of the framework.
So even though your app may be running .NET 4 or 4.5, you can use assemblies (or libraries) that were written for .NET 2 (although some restrictions may apply, as others have mentioned). Those assemblies just run under the 4.5 CLR (assuming there are no backwards compatibility issues with them), which is rare but does happen).
But the key to remember, your running application must be at the highest version of any contained assemblies. Meaning, if you have 4.5 assemblies, you can't run your app as a 2.0 app. It must be the other way around.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With