If am writing a VB.Net module for a project I am working on and have decided to try out different ways of doing some things, without getting rid of the older code that worked. I am selecting between these methods by setting a #Const at the beginning of the Module file, and using #If / #ElseIf / #Else / #End If to select the different methods in the code. I plan to later select each method one at a time and profile the results to see which is actually best (memory, speed, etc.) for my needs. I want to able to tell the compiler that I screwed up if I use an invalid value for the controlling #Const; at that point, I want to the compiler to stop and give me a configurable message. Sort of like VB.Net's Debug.Fail but at compile time, not run time.

What I am doing at this point is:

        #Error("An invalid ClllMethod was selected.  Go back to the top of the file and fix it.")
#End If

While this definitely gets the compiler to complain, it is not the error message I was expecting. I guess I am so used to C++'s #error and #warning directives and I am looking for that functionality in VB.Net. Can anybody give me some advice on how this is supposed to be handled in this language?

As far as I can tell there are no direct equivalents to those particular preprocessor directives. There is an interesting writeup here on using the VB.Net ppd's though.