title: How to make an exe that only runs with .NET 4.7.1
body: <p>I'm trying to create a simple console application that would run only if .NET 4.7.1 is installed, for testing purposes.</p>
  
  <p>I made a console application project and defined Target framework as <code>.NET Framework 4.7.1</code>.</p>
  
  <p>After compiling the project, if I run it on a machine without .NET 4.7.1, it still runs.</p>
  
  <p>Then, I tried to add some .NET 4.7.1 specific code that I <a href="https://blogs.msdn.microsoft.com/dotnet/2017/10/17/announcing-the-net-framework-4-7-1/" rel="nofollow noreferrer">found on the internet</a>, and it still runs on a machine without .NET 4.7.1 installed on it.</p>
  
  <pre><code>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&lt;int, string&gt; tuple1, (int, string) tuple2, Stream output)
      {
          IFormatter formatter = new BinaryFormatter();
          formatter.Serialize(output, tuple1);
          formatter.Serialize(output, tuple2);
      }
  
  }
  </code></pre>
  
  <p>What else can I do to make the application will only run if .NET 4.7.1 is installed on the machine?</p>