title: Compile a Visual Studio C# project for two TargetPlatformVersion
body: <p>I developed a .NET windows application which worked both on Windows 7 and 8.1. Then I added the Toast notification feature that came with Windows 8 (from this question: <a href="https://stackoverflow.com/questions/12745703">How can I use the Windows.UI namespace from a regular (Non-Store) Win32 .NET application?</a>).
  This also worked, I just had to add: </p>
  
  <p><code>&lt;PropertyGroup&gt;
      &lt;TargetPlatformVersion&gt;8.0&lt;/TargetPlatformVersion&gt;
  &lt;/PropertyGroup&gt;</code> </p>
  
  <p>to the project file.</p>
  
  <p>As I referenced the Windows.winmd file from the Windows 8.1 SDK <code>C:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral\Windows.winmd</code>, the executable does not start on Windows 7 anymore! I double-click and that's it. No errors, no messages.</p>
  
  <p>As I did not find any solution online, that's where my question comes up: How do I manage to do both: Offer the <strong>toast</strong> feature to my users AND make the same .exe <strong>run on Windows 7</strong>?</p>
  
  <p>Thank you in advance!</p>
  
  <p><strong>EDIT</strong>
  It turns out that though TargetPlatformVersion is set to 8.0, the executable starts on Windows 7 anyway, but crashes as soon as the program tries to load the Windows 8 libraries:</p>
  
  <p><code>An unhandled exception of type 'System.TypeLoadException' occurred in ToastTester.exe. 
  Additional information: Could not find Windows Runtime type 'Windows.UI.Notifications.ToastNotificationManager'.</code></p>
  
  <p>on line <code>Application.Run(new Form1());</code></p>
  
  <p>In Form1.cs in line 9 I've got <code>using Windows.UI.Notifications;</code></p>
  
  <p>What is the best way to avoid this exception during runtime, even though it is expected that this executable will run in environments like Windows 7 where the Windows.UI.Notifications namespace is definitely not available?</p>