2

I'm working on a WPF C# .NET project where I am utilizing some Windows 8.1 specific functionality by using the

<TargetPlatformVersion>8.1</TargetPlatformVersion>

in my .csproj. Ideally I would like to continue providing support to my non Windows 8.1 customers.

What is the best way to support Windows 8.1 specific functionality while still creating an exe compatible with older versions of Windows (.NET 4.0).

Thanks!

user1930728
  • 301
  • 1
  • 11

1 Answers1

2

You can use compile time constants and Project configurations to create different outputs for the same project.
In your code, you can check whether a compile time constant is set and (de-)activate blocks of code accordingly, e.g.:

#if DEBUG
    // Code when DEBUG constant is set
#else
    // Code when DEBUG constant is not set
#endif

However, Keep in mind that having separate builds for a project introduces new effort. If you have the chance to check at runtime whether the OS the application is running on supports some functionality it is much less effort.

Markus
  • 20,838
  • 4
  • 31
  • 55
  • Thanks for the tip. With your answer and another link I was able to get it working for me. Thanks again! The link with more detail on how to conditionally use references is here: http://stackoverflow.com/questions/2923210/c-sharp-conditional-compilation-and-framework-targets – user1930728 Nov 02 '13 at 13:33