How to inject C# Preprocessor Directives to an interface by Reflection ?
Example :
I want to inject #if SILVERLIGHT to any WCF service contract interface.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Short answer: you can’t.
Slightly longer answer: you question doesn’t even make sense in the first place.
Preprocessor directives are processed before compilation. The result of that processing is the new, modified, source code. That source code then gets compiled.
For example, if the
SILVERLIGHTsymbol is not defined at the time of compilation, then the whole code between#if SiLVERLIGHTand#endifwill be completely ignored by the compiler as if it wasn’t even there.