Null Propagation Operator Error BC36716 in ASP.NET 4.6 Target View

I have an MVC solution originally compiled in VS2013 targeting .NET 4.5. Anxiously waiting for the VS2015 spread operator, I opened the solution and recompiled in VS2015. I tested the following line in my controller and it worked fine:

Dim test = If(clientLocRec?.Website, clientRec.Website)

      

I was delighted! However, the same line in the corresponding view (in the code block) produces error code BC36716. Then I changed the target to .NET 4.6 and still get the error, but again only in the view. My questions are as follows:

  • Is this a bug or is it something I am doing wrong?
  • I assume 4.6 is required for runtime compilation in ASP.NET if I want to use some VS2015 language additions like spread operator. Am I correct in this assumption?
+3


source to share


1 answer


Add this Nuget package to your solution:

https://www.nuget.org/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform/

The nuget package should change your web.config, but check that the following config is in your web.config file (and if it doesn't add it):

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs"
        type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        warningLevel="4" compilerOptions="/langversion:6 /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.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+"/>
    </compilers>
  </system.codedom>

      



This happens right inside the element <configuration />

.

This will replace Roslyn-enabled code generators. After that, it will work in your shavers.

I believe MVC 5.2.3 or newer is required to work correctly.

+3


source







All Articles