Reputation: 6312
I am using some preprocessor commands in my project so that I can specify a connection string. Basically it's:
#if DEBUG
return @"Network connection 1"
#elif DEBUGLIVE
return @"Network connection 2"
#else
return @"Default connection"
#endif
However, though I am setting the solution in VS 2008 to Debuglive it is in fact passing back the dubug connection string, why is that?
Edit:
Ok, so I have not used the preprocessor commands before and I am not sure how they work. I am also working on projects which have been written by other people so I didn't know 'DEBUGLIVE' is something you have to create. So, my question is now, as I can't work it out from the other projects, how do you set up within your project settings 'DEBUGLIVE'?
Upvotes: 1
Views: 358
Reputation: 1
I was undergoing the same thing. The easiest way is to do like Davy8. In addition you will have to add a new build in the configuration manager. Just click the drop down under the Debug tab in VS 2017 and select configuration manager and in that select Add. Then you can name your DEBUGLVE and save. Also you have to specify in the web.config
Upvotes: 0
Reputation: 31596
Right-click on the project and go to Properties
from there go in Build. There should be a build called "Conditional compilation symbols".
You can add DEBUGLIVE to that list. You have set different symbols for different configurations, and they don't need to be the same name as the configuration (though it does make things easier to remember)
You'll notice underneath "Conditional compilation symbols" there's a checkbox for Define DEBUG constant. That's why the DEBUG one is getting hit because that is checked for default in a Debug configuration. As far as I know, it's simply a shortcut for typing DEBUG in the box above, and it would be functionally equivalent if you unchecked that box and typed DEBUG in the list of symbols.
Upvotes: 3
Reputation: 640
So, my question is now, as I can't work it out from the other projects, how do you set up within your project settings 'DEBUGLIVE'?
#define DEBUGLIVE
Upvotes: 0
Reputation: 373
Ensure that your solution configuration also sets the project configuration appropriately.
Upvotes: 0