Weird Error if you forget to reboot after BC installation

I was installing a new v14 on-premises today on a 2012R2 server, and encountered a new (for me) error:

The type initializer for ‘Roslyn.Utilities.TextKeyedCache`1’ threw an exception.

Looking closer at the trace, I found the message: Could not load file or assembly ‘System.ValueTuple

ValueTuple is a new type (struct) introduced in .Net Framework 4.7 so I was properly missing some DotNet stuff. And yes, at the end of the server installation, the installer asked to reboot the server (but I usually ignore those requests).

I rebooted the server, and now the server worked.

Moral of this story: If the installer asks for a reboot, you properly need to reboot 🙂

Below is the complete trace, to be search engine friendly for others who might hit the same error.

Server instance: BC140
Tenant ID: 
User: 
Type: System.TypeInitializationException
TypeName: Roslyn.Utilities.TextKeyedCache`1
Message: The type initializer for 'Roslyn.Utilities.TextKeyedCache`1' threw an exception.
StackTrace:
     at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LexerCache..ctor()
     at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.Lexer..ctor(SourceText text, CSharpParseOptions options, Boolean allowPreprocessorDirectives, Boolean interpolationFollowedByColon)
     at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(SourceText text, CSharpParseOptions options, String path, CancellationToken cancellationToken)
     at Microsoft.Dynamics.Nav.Runtime.CSharpCompiler..ctor()
     at Microsoft.Dynamics.Nav.Runtime.AssemblyGetter..ctor(TempPathHelper tempPathHelper)
     at Microsoft.Dynamics.Nav.Runtime.NCLCodeLoader..ctor(TempPathHelper tempPathHelper)
     at Microsoft.Dynamics.Nav.Runtime.NavSystemTenant..ctor(NavDatabaseServer databaseServer, String appDatabaseName)
     at Microsoft.Dynamics.Nav.Runtime.NavTenantCollection.AddSystemTenant(String appDatabaseServerName, String appDatabaseName, String appDatabaseUserName, ProtectedDatabasePassword appDatabasePassword, Boolean verifyConnection, String newEncryptionKey, IDatabasePasswordPublicEncryptionKeyStorage keyStorage, Boolean allowOverwritePublicKey, Boolean verifyServerInstanceKey)
     at Microsoft.Dynamics.Nav.Runtime.NavTenantCollection.AddSingleLegacyTenant(String databaseServerName, String databaseName, String databaseUserName, ProtectedDatabasePassword databasePassword, EncryptionProvider encryptionProvider, AzureKeyVaultSettings azureKeyVaultSettings)
     at Microsoft.Dynamics.Nav.Runtime.NavTenantCollection.ConfigureTenants(ServerUserSettings settings, String encryptionKey)
     at Microsoft.Dynamics.Nav.Runtime.NavTaskFactory.<>c__DisplayClass11_0.<StartNewTask>b__0()
     at System.Threading.Tasks.Task.Execute()
Source: Microsoft.CodeAnalysis.CSharp
HResult: -2146233036
StackTrace:
     at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.LexerCache..ctor()
     at Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.Lexer..ctor(SourceText text, CSharpParseOptions options, Boolean allowPreprocessorDirectives, Boolean interpolationFollowedByColon)
     at Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(SourceText text, CSharpParseOptions options, String path, CancellationToken cancellationToken)
     at Microsoft.Dynamics.Nav.Runtime.CSharpCompiler..ctor()
     at Microsoft.Dynamics.Nav.Runtime.AssemblyGetter..ctor(TempPathHelper tempPathHelper)
     at Microsoft.Dynamics.Nav.Runtime.NCLCodeLoader..ctor(TempPathHelper tempPathHelper)
     at Microsoft.Dynamics.Nav.Runtime.NavSystemTenant..ctor(NavDatabaseServer databaseServer, String appDatabaseName)
     at Microsoft.Dynamics.Nav.Runtime.NavTenantCollection.AddSystemTenant(String appDatabaseServerName, String appDatabaseName, String appDatabaseUserName, ProtectedDatabasePassword appDatabasePassword, Boolean verifyConnection, String newEncryptionKey, IDatabasePasswordPublicEncryptionKeyStorage keyStorage, Boolean allowOverwritePublicKey, Boolean verifyServerInstanceKey)
     at Microsoft.Dynamics.Nav.Runtime.NavTenantCollection.AddSingleLegacyTenant(String databaseServerName, String databaseName, String databaseUserName, ProtectedDatabasePassword databasePassword, EncryptionProvider encryptionProvider, AzureKeyVaultSettings azureKeyVaultSettings)
     at Microsoft.Dynamics.Nav.Runtime.NavTenantCollection.ConfigureTenants(ServerUserSettings settings, String encryptionKey)
     at Microsoft.Dynamics.Nav.Runtime.NavTaskFactory.<>c__DisplayClass11_0.<StartNewTask>b__0()
     at System.Threading.Tasks.Task.Execute()
----------------------------------
Type: System.IO.FileNotFoundException
Message: Could not load file or assembly 'System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
FileName: System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
FusionLog:
  WRN: Assembly binding logging is turned OFF.
  To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
  Note: There is some performance penalty associated with assembly bind failure logging.
  To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
  
StackTrace:    at Roslyn.Utilities.TextKeyedCache`1..cctor()
Source: Microsoft.CodeAnalysis
HResult: -2147024894
StackTrace:    at Roslyn.Utilities.TextKeyedCache`1..cctor()