I have a small command line application written in C#/.NET. I need it to run when .NET 3.5 or above is installed on the operating system.
To do so, I have the app.config contain the following:
<?xml version="1.0" encoding="utf-8" ?>
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
The project framework is setted to ".NET Framework 3.5".
From my understanding, these two settings should be backwards compatible so that when someone does not have 3.5 installed, but has 4.x installed, it will continue to work.
Is there something else I'm missing? From my research I thought that I had gotten all of the pieces together for this to work.
edit: Per the below question here are also the references and using statements. there are no third party components
the following are references in the project:
and the following are my using statements:
This is a known restriction of .NET Framework - starting with 4, it does not allow an app to be executed within its own runtime if the previous (in your case, target version) is not installed.
3.5 is based on a different CLR (2.0), hence some compat issues. You'd need to re-target your project to 4.0 (or later) to avoid the issue of the framework install prompt.
Recommended reading: CLR Inside Out - In-Process Side-by-Side