I am using Visual Studio 2010.
I've donwloaded an updated class (i.e. UpdatedClass.cs) which has a method with optional parameter, such as:
public void DoThis(bool aValue = false) {...}
Using Visual Studio 2010, I am able to compile it. But I cannot do it with MSBuild:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe /t:Rebuild /clp:ErrorsOnly D:\folder\mySolution.sln
ln
Microsoft (R) Build Engine Version 3.5.30729.5420
[Microsoft .NET Framework, Version 2.0.50727.5448]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
UpdatedClass.cs(29,94): error CS0241: Default parameter specifiers are not permitted
Well, optional parameters are not permitted using this compiler. So can I add an extra argument in this MSBuild command, to ignore this kind of error?
Or do I have to compile the project using C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
?
Is this safe regarding asp.net projects?
If you are using C# 4 syntax, you have to use a 4.0 compiler. And this means you need to run .Net 4.0 on the server where you intend to deploy this code. Alternatively - rewrite the code not to use default parameters, that's not hard - just add an overload like this:
public void DoThis() {DoThis(false);}
public void DoThis(bool aValue) {...}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With