0

I have some code that I want to run in Visual Studio's Immediate Window. It depends on a preprocessor directive. When I try to #Define it in there, I get error CS1525: Invalid expression term ''. My currently selected build configuration changes nothing here.

How can I run a static method, foo.bar.MyMethod(12345), in the Immediate Window if I need to #Define Test first?

J. Mini
  • 1,868
  • 1
  • 9
  • 38
  • You don't have a complete C# compiler available here, just an expression parser. Try to get ahead with View > Other Windows > C# Interactive, gives you a REPL with the Roslyn compiler. Although the odds that a #define could work in code that was already compiled previously are not good, hard to tell from the question. – Hans Passant May 24 '23 at 13:14
  • You cannot use preprocessor directives here. The immediate window doesn't seem to support defining symbols or executing code that relies on preprocessor directives. – wenbingeng-MSFT May 30 '23 at 09:41

0 Answers0