sdk: Result of chr() cannot be used as initial value of a Const in .Net Core 3 Preview 1

Version: 3.0.100-preview-009812 Commit: e3abf6e935

Runtime Environment: OS Name: Windows OS Version: 10.0.17763 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview-009812\

Host (useful for support): Version: 3.0.0-preview-27122-01 Commit: 00c5c8bc40

Have you experienced this same bug with .NET Framework?: No

In the .Net Framework using VB.Net you can compile this Line:

Private Const TabChar As Char = Chr(9)

In .Net Core 3 Preview 1 it failes with: error BC30059: Constant expression is required.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (12 by maintainers)

Commits related to this issue

Most upvoted comments

This works

  <Target Name="SetVBRuntimePath" AfterTargets="ResolveAssemblyReferences">
    <PropertyGroup>
      <VBRuntime Condition="'%(ReferencePath.FileName)' == 'Microsoft.VisualBasic'">%(ReferencePath.Identity)</VBRuntime>
    </PropertyGroup>
  </Target>

It is basically doing what @AlekseyTs said: if there’s an microsoft.visualbasic.dll in the references, use that. I will base the real fix around this.

@DualBrain as a workaround, you can set the VBRuntime property to default in your vbproj file and the embedded VB runtime will not be used, allowing the referenced MS.VB.dll to be used instead.

Hi, Any Update on this? I just tried to convert a VB.Net Project from the Old Project Format into the SDK Project Format and noticed that I ran into the Very same problem.