Skip to content

Attempting to run on mono.exe shipped with Unity game engine. CS1069: The type name 'Console' could not be found in the namespace 'System'. #1838

Closed as not planned
@Aidiakapi

Description

@Aidiakapi

I've been attempting to run some pure C# performance tests, but using the version of mono.exe and the BCL shipping with the Unity game engine.

However, after trying a lot of different ways to get it to run, it keeps showing these errors:

CS1069: The type name 'Console' could not be found in the namespace 'System'. This type has been forwarded to assembly 'System.Console, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.
CS1069: The type name 'Console' could not be found in the namespace 'System'. This type has been forwarded to assembly 'System.Console, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.
CS1503: Argument 2: cannot convert from 'System.Text.Encoding' to 'bool'
CS1069: The type name 'Enumerable' could not be found in the namespace 'System.Linq'. This type has been forwarded to assembly 'System.Linq, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.
CS1069: The type name 'Enumerable' could not be found in the namespace 'System.Linq'. This type has been forwarded to assembly 'System.Linq, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.
CS1069: The type name 'Enumerable' could not be found in the namespace 'System.Linq'. This type has been forwarded to assembly 'System.Linq, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.

This is the configuration used:

	public class UnityMonoConfig : ManualConfig
	{
		public UnityMonoConfig() {
			WithOption(ConfigOptions.KeepBenchmarkFiles, true);
			var job = Job.Dry.WithRuntime(new MonoRuntime(
				"Mono x64",
				@"M:\Unity\Data\MonoBleedingEdge\bin\mono.exe",
				null,
				@"M:\Unity\Data\MonoBleedingEdge\lib\mono\unityjit-win32"
			));
			AddJob(job);
		}
	}

It is with Unity engine version 2021.2.
It seems to be tangentially related to #1390 and #1392, however, the remedy of switching the test project itself to .NET 4.x does not work, since these projects are on netstandard2.1, which is not supported. Instead the test runner project is running on .NET 5, with the tested project being aforementioned netstandard2.1.

I've tried adding NuGet references, but the RoslynToolchain does not support that, switching to different toolchains either does not work, or in case of the InProcessEmit toolchains, they do not actually run Mono.

When inspecting the Dry.bat, I can see that it's referencing various .dll's from .NET 5:
/reference:"C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.11\System.Runtime.dll","C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.11\System.Collections.dll"

However, that should be fine, since it's only compiling the benchmark code, and I don't think that's where it trips up.

I've tried adding various references to the test runner project, but nothing seems to help, this is the project:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net5.0</TargetFramework>
        <LangVersion>9</LangVersion>
        <OutputType>Exe</OutputType>
    </PropertyGroup>

    <ItemGroup>
      <PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
      <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2">
        <PrivateAssets>all</PrivateAssets>
        <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      </PackageReference>
      <PackageReference Include="System.Console" Version="4.3.1" />
      <PackageReference Include="System.Linq" Version="4.3.0" />
    </ItemGroup>

    <ItemGroup>
      <ProjectReference Include="..\Shared.Core\Shared.Core.csproj" />
    </ItemGroup>

</Project>

What should I do to get this to work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions