Environment
| Product | Version |
|---|---|
| Progress® Telerik® JustMock | 2024.1.124.247 |
Description
While using JustMock, an initialization exception is thrown with the message: "The type initializer for 'Telerik.JustMock.Core.ProfilerInterceptor' threw an exception." This issue indicates a version mismatch between the referenced Telerik.JustMock.dll and the Telerik.CodeWeaver.Profiler.dll.
Cause
The error occurs due to different versions of the JustMock package referenced in the project and the locally installed JustMock product. Specifically, the exception message highlights an incompatible profiler version, which prevents proper initialization.
Solution
To resolve the issue, consider the following approaches:
Align the Versions
Ensure that the version of the JustMock package referenced in your project matches the version of the locally installed JustMock product. This alignment will eliminate the version incompatibility and allow the profiler to initialize correctly.
Use runsettings to Prepare the Profiler Environment
If aligning the versions is not feasible or you prefer a different approach, you can disable the JustMock Visual Studio Extension and manually configure the profiler environment using a .runsettings file. This method requires specifying JustMock settings within the .runsettings file to correctly prepare the environment for JustMock's profiler.
Follow these steps to configure the .runsettings file:
- Create a
.runsettingsfile in your solution. - Include the necessary JustMock configuration settings in the
.runsettingsfile. Refer to the official Microsoft documentation on configuring unit tests using a.runsettingsfile for the exact syntax and options. - Specify the path to the
.runsettingsfile in your test runner configuration.
For detailed instructions on using the NuGet package in .runsettings, consult the JustMock documentation.