I'm trying to create a simple console application that would run only if .NET 4.7.1 is installed, for testing purposes.
I made a console application project and defined Target framework as .NET Framework 4.7.1
.
After compiling the project, if I run it on a machine without .NET 4.7.1, it still runs.
Then, I tried to add some .NET 4.7.1 specific code that I found on the internet, and it still runs on a machine without .NET 4.7.1 installed on it.
class Class1
{
// This method return type will have an attribute (in IL) of type `IsReadOnly`
public ref readonly int Method2() { throw null; }
void Serialize(System.ValueTuple<int, string> tuple1, (int, string) tuple2, Stream output)
{
IFormatter formatter = new BinaryFormatter();
formatter.Serialize(output, tuple1);
formatter.Serialize(output, tuple2);
}
}
What else can I do to make the application will only run if .NET 4.7.1 is installed on the machine?