Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a TypeInitializationException after upgrading to NUnit Console Runner 3.16.0 and NUnit 3.13.3. #1280

Closed
varnk opened this issue Dec 12, 2022 · 7 comments

Comments

@varnk
Copy link

varnk commented Dec 12, 2022

This is occurring on a Windows 7 system that has .NET 4.6.1. The installation of NUnit components was done via Nuget within Visual Studio 2022. The NUnit test project was compiled targeting .NET 4.6.1.

Note that the Console Runner is able to run on the system where I have VS 2022 installed. However, it will not run on the test agent that doesn't have VS 2022 installed even though it used to run on that agent with Console Runner 3.14.0. Note that the test agent has .NET 4.8 installed on it in addition to .NET 4.6.1.

Behavior is no different when running with --inprocess.

 System.TypeInitializationException : The type initializer for 'NUnit.Engine.Services.RuntimeFrameworkService' threw an exception.
19:07:29    ----> System.ComponentModel.Win32Exception : The system cannot find the file specified
19:07:29  
19:07:29  --TypeInitializationException
19:07:29  The type initializer for 'NUnit.Engine.Services.RuntimeFrameworkService' threw an exception.
19:07:29     at NUnit.Engine.Services.RuntimeFrameworkService.ApplyImageData(TestPackage package)
19:07:29     at NUnit.Engine.Services.RuntimeFrameworkService.ApplyImageData(TestPackage package)
19:07:29     at NUnit.Engine.Services.RuntimeFrameworkService.SelectRuntimeFramework(TestPackage package)
19:07:29     at NUnit.Engine.Runners.MasterTestRunner.GetEngineRunner()
19:07:29     at NUnit.Engine.Runners.MasterTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
19:07:29     at NUnit.Engine.Runners.MasterTestRunner.Run(ITestEventListener listener, TestFilter filter)
19:07:29     at NUnit.ConsoleRunner.ConsoleRunner.RunTests(TestPackage package, TestFilter filter)
19:07:29     at NUnit.ConsoleRunner.ConsoleRunner.Execute()
19:07:29     at NUnit.ConsoleRunner.Program.Main(String[] args)
@CharliePoole
Copy link
Collaborator

As an experiment, can you install .NET 4.6.2 and try to run?

@chevydensing
Copy link

chevydensing commented Dec 14, 2022

I encountered the same time error message. Below are my versions:

installed in project:
target = .NET Core 6
nunit = 3.13.2
nunit3testadapter = 4.3.1

nunit.consolerunner = 3.16.0

Update 1: I installed the .netcore 6 SDK on the target machine and it worked
Update 2: Update 1 worked when I ran the consolerunner from the machine itself; but when issued the command from our CI app (Octopus), the error was the same
Update 3: We have made the run from CI app work by installing also the .netcore 7 SDK on the target machine

@varnk
Copy link
Author

varnk commented Dec 14, 2022

As an experiment, can you install .NET 4.6.2 and try to run?

Ran the installer for .NET 4.6.2, but it completed rather quickly. Maybe because .NET 4.8 is already installed.
I thought that .NET 4.8 is supposed to be downward compatible with earlier versions of .NET Framework, so maybe that is the reason why.

Anyhow, after running the .NET 4.6.2 installer and trying the console runner again I still get the same error.

BTW..., I ran a PS query to list .NET versions and here is what I got:

PSChildName                                                         Version                                                            
-----------                                                         -------                                                            
v2.0.50727                                                          2.0.50727.5420                                                     
v3.0                                                                3.0.30729.5420                                                     
Windows Communication Foundation                                    3.0.4506.5420                                                      
Windows Presentation Foundation                                     3.0.6920.5011                                                      
v3.5                                                                3.5.30729.5420                                                     
Client                                                              4.8.03761                                                          
Full                                                                4.8.03761                                                          
Client                                                              4.0.0.0                                                            


@nb77qlik
Copy link

Having the same issue on a Windows 10 TeamCity VM (it works fine on my local Windows 10 VM which has exact same versions installed).

CLR version:

C:\Windows\System32>clrver

Microsoft (R) .NET CLR Version Tool  Version 4.6.1055.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Versions installed on the machine:
v2.0.50727
v4.0.30319

Log output:

01:08:29   Starting: <REDACTED>\NUnit.ConsoleRunner.3.16.0\tools\nunit3-console.exe <REDACTED>
01:08:29   in directory: <REDACTED>
01:08:30   Runtime Environment
01:08:30      OS Version: Microsoft Windows NT 6.2.9200.0
01:08:30      Runtime: .NET Framework CLR v4.0.30319.42000
01:08:30   Test Files
01:08:30       <REDACTED>
01:08:30   System.TypeInitializationException : The type initializer for 'NUnit.Engine.Services.RuntimeFrameworkService' threw an exception.
01:08:30     ----> System.ComponentModel.Win32Exception : The system cannot find the file specified
01:08:30   --TypeInitializationException
01:08:30   The type initializer for 'NUnit.Engine.Services.RuntimeFrameworkService' threw an exception.
01:08:30      at NUnit.Engine.Services.RuntimeFrameworkService.ApplyImageData(TestPackage package)
01:08:30      at NUnit.Engine.Services.RuntimeFrameworkService.ApplyImageData(TestPackage package)
01:08:30      at NUnit.Engine.Services.RuntimeFrameworkService.ApplyImageData(TestPackage package)
01:08:30      at NUnit.Engine.Services.RuntimeFrameworkService.SelectRuntimeFramework(TestPackage package)
01:08:30      at NUnit.Engine.Runners.MasterTestRunner.GetEngineRunner()
01:08:30      at NUnit.Engine.Runners.MasterTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
01:08:30      at NUnit.Engine.Runners.MasterTestRunner.Run(ITestEventListener listener, TestFilter filter)
01:08:30      at NUnit.ConsoleRunner.ConsoleRunner.RunTests(TestPackage package, TestFilter filter)
01:08:30      at NUnit.ConsoleRunner.Program.Main(String[] args)
01:08:30   --
01:08:30   Win32Exception
01:08:30   The system cannot find the file specified
01:08:30      at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
01:08:30      at NUnit.Engine.Internal.RuntimeFrameworks.NetCoreFrameworkLocator.<GetRuntimeList>d__3.MoveNext()
01:08:30      at NUnit.Engine.Internal.RuntimeFrameworks.NetCoreFrameworkLocator.<FindDotNetCoreFrameworks>d__1.MoveNext()
01:08:30      at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
01:08:30      at NUnit.Engine.RuntimeFramework.FindAvailableFrameworks()
01:08:30      at NUnit.Engine.RuntimeFramework.get_AvailableFrameworks()
01:08:30      at NUnit.Engine.Services.RuntimeFrameworkService..cctor()
01:08:30   Process exited with code -100
01:08:30   NUnit process finished with negative exit code -100 (unexpected failure). Reporting step failure.

@CharliePoole
Copy link
Collaborator

What dotnet runtimes are installed? dotnet --list-runtimes

@varnk
Copy link
Author

varnk commented Dec 15, 2022

dotnet command doesn't exist on the target machine in my environment, likely because .Net core is not installed. Only .Net 4.6.1 SDK and .Net 4.8 Framework are installed.

@CharliePoole
Copy link
Collaborator

In that case, this is a duplicate of #1277, which was closed. The fix is available from our MyGet feed as version 3.16.1-dev00006

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants