0

I am in the process of switching to a new laptop. I copied all the files over and have a VS.NET solution with a large web site(can't convert this to a web application as it is too big and don't have the time now). I'm able to build the site on my old laptop but get this error when I try it on my new one:

Feature 'using static' is not available in C# 5. Please use language version 6 or greater

I looked at the following but did not find an answer that fits my situation:

The solution at Feature 'interpolated strings' is not available in C# 5. Please use language version 6 or greater doesn't work because I don't see the Advanced button in the Build dialog box.

I also looked at How to use C# 6 with Web Site project type? but found the solution doesn't work for me either. I tried to get the latest Microsoft.CodeDom.Providers.DotNetCompilerPlatform but still get the same error.

Here's the code the error is occurring on:

using static ClientUploadToolValueMapping;

The target framework for the web site on both my old and new laptop is 4.6.1. Both are also using VS.NET 2019.

Does anyone have any ideas on what the issue could be? Thanks.

Andre
  • 13
  • 7
  • You posted almost exactly the same question an hour ago: https://stackoverflow.com/questions/68134868/feature-using-static-is-not-available-in-c-sharp-5-please-use-language-versio If you want to add something to your old question, you can edit it. – Klaus Gütter Jun 25 '21 at 19:03
  • 1
    Does this answer your question? [Feature 'using static' is not available in C# 5. Please use language version 6 or greater in VS.NET 2019](https://stackoverflow.com/questions/68134868/feature-using-static-is-not-available-in-c-sharp-5-please-use-language-versio) – Klaus Gütter Jun 25 '21 at 19:03
  • When you read [the documentation](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/using-static) did it give you any inspiration? Was there anything that didn't make sense on the doc pages, that we can maybe help clarify? Remove the statement and resolve all the places it was used by qualifying the type name. Or upgrade the language version used – Caius Jard Jun 25 '21 at 19:03
  • Klaus - After my original post, Stackoverflow tagged it as a duplicate with another. I checked out the other post but did not find my answer. I initially wanted to edit my original post, but Stackoverflow said if I cannot find any answer to ask a new question. Sorry about the duplicate posts. – Andre Jun 25 '21 at 19:24
  • Caius - Thanks for the link, but it did not give me any inspiration or clarification. I believe the problem is some setting in Visual Studio. – Andre Jun 25 '21 at 19:26

1 Answers1

0

I found the solution. It turns out the web.config file on my new laptop was missing these elements:

<system.codedom>
    <compilers>
        <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
        <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
    </compilers>
  </system.codedom>
Andre
  • 13
  • 7