1

Everything runs fine locally, but I'm getting an "Unreachable code detected" error.

Here is that piece of code:

private string GetRedirectUriForCurrentConfiguration()
{
    #if (DEBUG || DebugDev)
        return "http://localhost:1855/";
    #endif
    return "http://172.16.40.39:1855";
}

I'm getting the "unreachable" message on the 4th line, at return "http://172.16.40.39:1855";

Is this statement setup correctly?

Brian
  • 25,523
  • 18
  • 82
  • 173
  • 5
    Its not an error it's a warning. **If** you are in debug mode `return "http://172.16.40.39:1855";` will be unreachable, that's what the warning is about. – Alexander Derck Mar 31 '16 at 21:45
  • In Visual Studio on the Ribbon Bar you can switch the build configuration via drop down. – aguertin Mar 31 '16 at 21:47

1 Answers1

9

Just add an #else preprocessor directive to your code:

private string GetRedirectUriForCurrentConfiguration() {

#if (DEBUG || DebugDev)
    return "http://localhost:1855/";
#else
    return "http://172.16.40.39:1855";
#endif  
}
Brian
  • 3,850
  • 3
  • 21
  • 37
  • 5
    Right. OP's code is the equivalent of 2 consecutive `return` statements when in debug mode. With this, it's one or the other regardless of debug mode or not. Therefore, no warning. – Broots Waymb Mar 31 '16 at 21:52