Handle the “Profiler must be enabled” exception.
There are several things you can do, if you get “Profiler must be enabled” exception during the execution of one or more of your tests.
First of all I have to object that JustMock uses its profiler when it is set to mock non-virtual, sealed or static objects. However, mocking virtual or non-sealed objects for example, should not lead to such an error. This leads to the first situation you may be experiencing:
Telerik JustMock is known in its two versions: JustMock Free and JustMock Commercial. The main difference between them is that the free version is not allowed to use the profiler. Therefore if you are trying to mock non-virtual, sealed or static objects for example, you will see the “Profiler must be enabled” error. For full comparison about the two versions you can check this link:
Note that all the other points in this article are written for the commercial version of Telerik JustMock.
While using Visual Studio for writing your tests you will notice the Telerik menu and the JustMock menu-item in it. Once there, you have to check if JustMock is enabled(“Enable JustMock” should be grey, see the example bellow).
One of the reasons for not working profiler may be that there is a conflict between two or more different profiler APIs. To avoid that be sure you have disabled/uninstalled programs, which can lead to such thing (programs like: TypeMock Isolator). Also, make sure all the Visual Studio profilers are disabled when executing your tests (IntelliTrace, CodeCoverage).
We recommend using one of the officially supported test runners: NUnit, TestDriven.Net, MSTest or JustCode.
A way to check if the profiler is working as expected is to use test method that will assert this:
If the above three steps don`t help, you can check the application events log for possible errors. If the JustMock profiler is loaded, you should see an event with ID 1022 and type “Information”. Else you will find an event with ID 1022 and type “Error”.
In this case, we recommend you to register the profiler DLLs manually. You can do this by opening the command prompt as an administrator and executing the following commands:
regsvr32.exe C:\Program Files (x86)\Telerik\JustMock\Libraries\CodeWeaver\32\Telerik.CodeWeaver.Profiler.dll
regsvr32.exe C:\Program Files (x86)\Telerik\JustMock\Libraries\CodeWeaver\64\Telerik.CodeWeaver.Profiler.dll
Another cause of the “Profiler must be enabled” exception may be that your Telerik.CodeWeaver.Api.dll is out of date. If you are using the latest version of Telerik.JustMock.DLL in your tests, be sure you have the latest profiler registered as well, otherwise they are supposed to fail.
To achieve this you will have to replace the old Telerik.CodeWeaver.Api.DLL, which is located in: “C:\Program Files (x86)\Telerik\JustMock\Libraries\” with the new one.
Also if you have updated from JustMock Q1 2012 or prior version, you will have to update the Telerik.JustMock.DLL references in you project too. This is due to a recent profiler ID change.
If you have tried every step listed above and there is still no result, you can always contact the Telerik Support Central for further assistance. It will be good to send the log file from step 4 and give us more details about the environment you are running the profiler against.
Other thing you can try is to run the test on different box or virtual machine, where you do not have any other extensions installed.
You may also want to check for solution in our forum:
Article relates to
Last modified by