0

the VS2015 "SQL Server Database Project" template does not support SQLCLR functions with C#6.0 (.Net4.6) to be compiled. The error message is

"CSC: Error: CS1617: Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default".

I have searched and found a lot for web projects like, e.g. Error Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default

Here you shall change the compiler in the web.config, like

type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

But me, I do not have an app, nor a web.config in my database project. So what can I do to set the compiler for this project? Thanks a lot.

Solomon Rutzky
  • 46,688
  • 9
  • 128
  • 171
Hans
  • 33
  • 4
  • Finally I found this page https://www.codesd.com/item/using-an-incorrect-compiler-when-building-the-sql-server-database-project.html and it describes exactly what I got as my personal conclusion. – Hans Nov 30 '17 at 08:11
  • It works with msbuild (\Program Files (x86)\MSBuild\14.0\Bin) on command line but me I've reverted the changes back to C#5.0. Until I can move to VS2017, where the SQL project file uses an actual compiler. – Hans Nov 30 '17 at 10:11

1 Answers1

1

This seems very similar to, and maybe a duplicate of, the following question, also here on S.O.:

Automatically implemented properties must define both get and set accessors

The issue is the C# compiler being used. If you go to a Developer Command Prompt and run CSC.exe, you should see a banner stating that the compiler only supports up to C# 5. And it provides a URL where to get a newer compiler from.

If the compiler does need to be specified in the project, then it would likely need to be manually added to the .sqlproj file, though there does not appear to be an existing element there already to set this value.

Solomon Rutzky
  • 46,688
  • 9
  • 128
  • 171
  • Thanks, you got me on the right track. So with just updating VS2015 and .Net SDK versions I cannot get to a running version because there is a compiler given ("Microsoft (R) Visual C# Compiler version 4.7.2558.0 for C# 5") with .Net 4.7.1 SDK (the actual one right now) that does still not support C#6.0. I really did not expect that. – Hans Nov 29 '17 at 10:36