Disasmo
Disasmo copied to clipboard
TypeLoadException
Visual Studio 2019 Preview 3.0 .NET Core 3.0 Console Application
Code to reproduce:
using System;
using System.Runtime.Intrinsics.X86;
namespace ConsoleApp1
{
class Program
{
static unsafe void Main(string[] args)
{
Console.WriteLine("Hello World!");
DoTest();
Console.WriteLine($"Is sup: {Sse42.IsSupported}");
}
static unsafe void DoTest()
{
var srcBuf = stackalloc[] { (byte)0xF0, (byte)0xF0, (byte)0xF0, (byte)0xF0 };
var dstBuf = stackalloc[] { (byte)0xF0, (byte)0xF0, (byte)0xF0, (byte)0xF0 };
var cvrBuf = stackalloc[] { (byte)0xF0, (byte)0xF0, (byte)0xF0, (byte)0xF0 };
var alphaBuf = stackalloc[] { (byte)0xF0, (byte)0xF0, (byte)0xF0, (byte)0xF0 };
var csmBuf = stackalloc[]
{
(byte)0x00,
(byte)0xFF,
(byte)0xFF,
(byte)0xFF,
(byte)0x01,
(byte)0xFF,
(byte)0xFF,
(byte)0xFF,
(byte)0x02,
(byte)0xFF,
(byte)0xFF,
(byte)0xFF,
(byte)0x03,
(byte)0xFF,
(byte)0xFF,
(byte)0xFF
};
var onesBuf = stackalloc[]
{
(byte)0x01,
(byte)0x00,
(byte)0x00,
(byte)0x00,
(byte)0x01,
(byte)0x00,
(byte)0x00,
(byte)0x00,
(byte)0x01,
(byte)0x00,
(byte)0x00,
(byte)0x00,
(byte)0x01,
(byte)0x00,
(byte)0x00,
(byte)0x00,
};
var length = 4;
var rCvr = Sse42.LoadVector128(cvrBuf);
var rSrc = Sse42.LoadVector128(srcBuf);
for (int i = 0; i < length; i++)
{
rCvr = Sse42.Shuffle(rCvr, Sse42.LoadVector128(csmBuf));
rCvr = Sse42.Add(rCvr, Sse42.LoadVector128(onesBuf));
}
}
}
}
"Disasm 'DoTest' method" fails with:
Unhandled Exception: System.TypeLoadException: Could not load type 'Internal.Runtime.Augments.EnvironmentAugments' from assembly 'System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
at System.Environment.get_CurrentManagedThreadId()
at System.Linq.Enumerable.Where[TSource](IEnumerable`1 source, Func`2 predicate)
at ConsoleApp1.Program.Main(String[] args)
Unfortunately I've not solved this problem yet.
It occurs when your system CoreCLR and the local one have this kind of differences (e.g. in more recent CoreCLR a type was moved/renamed).
I need to figure out how to 100% use only local CoreCLR when I do restore & publish
.
Currently it uses the latest system dotnet sdk & runtime to restore and then replaces some binaries with the local ones.
I suspect that I should use --fx-version
switch (but it's not available yet?)
As a workaround - update to the latest daily build of CoreCLR and update your local coreclr to the master.