This is a migrated thread and some comments may be shown as answers.

How to load correct profiler

1 Answer 323 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Hendrik
Top achievements
Rank 1
Hendrik asked on 17 Jun 2016, 06:34 AM

Hi everyone,

 

I'm having problems with the profiler of JustMock.

 

The Unit Test 

[Test]
        public void Profiler_IsEnabled()
        {
            Assert.IsTrue(Mock.IsProfilerEnabled);
        }

currently fails.

 

For certain mocks, I get the error message :

Telerik.JustMock.Core.ElevatedMockingException : Cannot mock 'Microsoft.SharePoint.SPContext'. The profiler must be enabled to mock, arrange or execute the specified target.
Detected active third-party profilers:
* {DA7CFC47-3E35-4c4e-B495-534F93B28683} (from global system environment)
* {DA7CFC47-3E35-4c4e-B495-534F93B28683} (from process environment)
Disable the profilers or link them from the JustMock configuration utility. Restart the test runner and, if necessary, Visual Studio after linking.
   bei Telerik.JustMock.Core.ProfilerInterceptor.ThrowElevatedMockingException(MemberInfo member)
   bei Telerik.JustMock.Core.MocksRepository.InterceptStatics(Type type, IEnumerable`1 mixins, IEnumerable`1 supplementaryBehaviors, IEnumerable`1 fallbackBehaviors, Boolean mockStaticConstructor)
   bei Telerik.JustMock.MockBuilder.InterceptStatics(MocksRepository repository, Type type, Nullable`1 behavior, Boolean mockStaticConstructor)
   bei Telerik.JustMock.Core.MocksRepository.ConvertExpressionToCallPattern(Expression expr, CallPattern callPattern)
   bei Telerik.JustMock.Core.MocksRepository.Arrange[TMethodMock](Expression expr, Func`1 methodMockFactory)
   bei Telerik.JustMock.Core.ProfilerInterceptor.GuardInternal[T](Func`1 guardedAction)
   bei Urlaubswesen.Tests.TestsHelper.GetUrlaubsantragSpListItem(SPUser antragsstellerSpUser, DateTime urlaubsbeginnDateTime, DateTime urlaubsendeDateTime, String urlaubstyp, Boolean sonderurlaub, String begruendungSonderurlaub) in C:\_Weist\Urlaubswesen\Urlaubswesen\Urlaubswesen.Tests\TestsHelper.cs:Zeile 74.
   bei Urlaubswesen.Tests.TestsHelperTests.GetUrlaubsantragMock.GetUrlaubsantragMock_KeinSonderurlaub_IsCorrect() in C:\_Weist\Urlaubswesen\Urlaubswesen\Urlaubswesen.Tests\TestsHelperTests.cs:Zeile 36.

In the event log, I get the information

.NET Runtime version 4.0.30319.0 - Der Profiler wurde erfolgreich geladen. Profiler-CLSID: "{DA7CFC47-3E35-4c4e-B495-534F93B28683}".  Prozess-ID (dezimal): 25912. Meldungs-ID: [0x2507].

 

As you can see on the screenshots, the profiler is enabled in the menu. But I don't know if I selected the right profiler. In the list, no profiler corresponding to JustMock is even available. 

How do I select the right profiler in order to solve this problem?

Thank you very much!

 

 

 

1 Answer, 1 is accepted

Sort by
0
Svetlozar
Telerik team
answered on 21 Jun 2016, 03:25 PM
Hi,

I am really sorry for the inconvenience!

The CLR can have only one profiler attached to a process. It looks like on your side there is a dynatrace profiler that is launched instead of JustMock. 

We have a a feature to chain other profilers after JustMock (the screenshot of JustMock configuration tool), but for that to work it must be the JustMock profiler attached to the process. 

Under the hood setting the profiler is just setting COR_PROFILER environment variable to the profiler GUID. Can you try to somehow stop the dynatrace profiler and disable/enable JustMock profiler. Disable/Enable JustMock profiler will reset the COR_PROFILER variable to the JustMock guid. The question is how to prevent dynatrace profiler to reset it as it looks from the exception details.

* {DA7CFC47-3E35-4c4e-B495-534F93B28683} (from process environment)

Regards,
Svetlozar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Hendrik
Top achievements
Rank 1
Answers by
Svetlozar
Telerik team
Share this question
or