c# - Check the operating system at compile time? -



c# - Check the operating system at compile time? -

i running windows 7 64-bit operating scheme on development machine, using .net 4.5 , ms visual studio 2012. have several c# projects utilize system.threading.task namespace. want able build these projects on server of our developers have access to. problem that server running windows server 2003, not back upwards .net 4.5, , system.threading.task namespace not exist in versions of .net before 4.5.

i can set new build configurations compile-time constant can check determine namespace include, before that, i'm wondering if there's pre-defined constant can use. uncertainty it, since far know compile-time constants can defined or not defined in c#, unlike c++ in can have specific values.

first, task namespace (or rather, tasks namespace) did exist in .net 4.0, albeit far more limited features (read: fewer sugar methods) , no async/await keywords. though more limited, may help open possibility setting platform programme .net 4.0, resolves lot of issues.

while cannot utilize compile time constants (ie items marked const keyword) exclude/include code, can utilize symbol definition via #if directive. long arrange symbols properly, can effective way separate compiled code, since &, |, , nested #ifs allowed , work expected.

regardless of included namespaces, however, programme built against .net 4.5 still going run 4.5 , won't work on machine doesn't back upwards it, if features utilize available in 4.0. in addition, can't alter .net platform per build configuration, might able away making mirror project invokes same files , folders, instead builds against 4.0. in all, advise going 4.0 reading next update , going mono instead.

update: alternative might consider mono as, according download page, newest mono maintains compatibility windows xp , server 2003. advise getting xamarin can test run code against mono platform, note mono reads same il .net does, , xamarin designed read/write same project , solution formats vs.

c# visual-studio-2012

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -