runtime: [RC1] Could not load type 'System.Utf8String' from assembly 'System.Utf8String.Experimental

Problem

Unable to use Utf8String in 5.0 RC1 SDK (5.0.0-rc.1.20423.8), it works fine in 6.0 alpha (6.0.100-alpha.1.20428.8)

Unhandled exception. System.TypeLoadException: Could not load type 'System.Utf8String' from assembly 'System.Utf8String.Experimental, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
   at repro.Program.Main()

Repro:

The following code fails when using 5.0.0-rc.1.20423.8 SDK:

using System;

namespace repro
{
    class Program
    {
        static void Main() => Console.WriteLine(new Utf8String("Hello World!"));
    }
}
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net5.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.Utf8String.Experimental" Version="5.0.0-preview.8.20352.3" />
  </ItemGroup>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="nuget" value="https://api.nuget.org/v3/index.json" />
    <add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
  </packageSources>
</configuration>

The problem is currently blocking performance repo from switching to release/5.0.1xx channel for downloading net5.0 SDK (so far we were using master channel but it’s time to switch to 5.0 as master contains now 6.0 bits): https://github.com/dotnet/performance/pull/1484

@GrabYourPitchforks @eerhardt is there any chance that someone could take a look at this?

/cc @ooooolivia

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 18 (18 by maintainers)

Most upvoted comments

But how can we then use this type in net5.0 apps? Even for “experiments”?

You cannot. The plan for this is to move experiment like this to dotnet/runtimelab and allow you to publish self-contained apps if you want to play with experimental features like Utf8String.

why would you expect something different than a TypeLoadException here?

I am installing a NuGet package, writing code that compiles perfectly fine, and then I am trying to run it. Once I get TypeLoadException my first thought is that I am missing some dependency (a .dll file) or there is a .dll version mismatch. Since it worked just a few days ago, I am very confused.

The type is missing. We aren’t shipping this package.

If the type has been removed from net5.0 I should get a compiler error that indicates that.

We definitely don’t want to ship some random prerelease version in corelib…

This is perfectly fine, but please be clear about this. Give me an error that says it and I won’t be creating new issues and wondering whether SDK installer is broken or something was removed, but not 100% removed.

If it was not, it suggests we may have a UTF8Encoding coverage hole.

I’ve sent a PR to address that: https://github.com/dotnet/performance/pull/1491

I believe that is expected. We don’t want experimental types in release builds. They are experimental, not to be released.

I hit this too.

Also ran into issues with the deprecation of binary formatter, the suggested suppression via SYSLIB0011 did not work and the only way I could get things to build was to delete the files that had binary formatter tests.