I have a library with the following code:
double result = -1; if (!string.IsNullOrEmpty(fieldName)) { string value = HttpContext.Current.Request.QueryString[fieldName]; if (string.IsNullOrEmpty(value)) { value = HttpContext.Current.Request.Form[fieldName]; } if (string.IsNullOrWhiteSpace(value) || !double.TryParse(value.Trim(), out result)) { result = -1; } } return result;
In my local copy of Visual Studio 2015, this compiles fine. Last week, the build server enabled this compilation without any problems. Unexpectedly on Monday, an error occurred on the build server:
QueryParser.cs (449.53): error CS1620: Argument 2 must be passed with the keyword 'ref' [$ projectPath \ Core40.csproj]
When I make this switch (using ref instead of out ), the build server can complete the build without errors, but Visual Studio will no longer compile.
From my reading of the relevant documentation, double.TryParse always executed the out keyword, so there must be something not in the build server libraries, but I'm not sure what and how to diagnose it.
After some of the questions below, I went back to the class and confirmed that there are several instances of decimal.TryParse(value, out result) , int.TryParse(value, out result) , float.TryParse(value, out result) , long.TryParse(value, out result) and Guid.TryParse(value, out result) . I was also able to replace "double" with "float" and it worked perfectly. This is something special for double .
Apparently the build command:
msbuild /m /p:Configuration=Release /p:Platform="Any CPU" $path\$solution.sln
In addition, I can replace TryParse with a try { return double.Parse(value); } catch (Exception) { return DEFAUlT; } block try { return double.Parse(value); } catch (Exception) { return DEFAUlT; } try { return double.Parse(value); } catch (Exception) { return DEFAUlT; } try { return double.Parse(value); } catch (Exception) { return DEFAUlT; } (my temporary way forward), but this does not actually solve the problem.