6

I am using VS2015 with Update 3. I have a simple hello world unit test project where I am trying to get the shimContext , below is the code snippet. I am getting the exception at shimContext to create call: *

Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException' occurred in Microsoft.QualityTools.Testing.Fakes.dll Additional information: Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables.

*

 [TestClass]
    public class UnitTest1
    {

        private IDisposable shimsContext;

        [TestMethod]
        public void TestMethod1()
        {
            shimsContext = ShimsContext.Create();
            Assert.IsTrue(true);
        }
    }

I have browsed a lot of articles on StackOverflow, MSDN regarding the suggested workarounds and none of them seem to resolve the issue. Following are the list of workarounds I have tried.

  1. To use a unit test runner that initializes IntelliTrace during startup (used two plugins CodeRush and Resharper both yield same exception).
  2. To link a .runsettings file with ForcedLegacyMode - True, this also yielded the same exception.
  3. A sample demo unit test trying to create a shimsContext was created to verify if the problem is isolated to the environment.

  4. Run vstest.console.exe via command line to verify if tests are running in the command line, this too gave the same exception.

Any suggestions/advice?

Thanks - Keerti.

Reza Mousavi
  • 4,420
  • 5
  • 31
  • 48
Somu
  • 515
  • 1
  • 5
  • 12
  • Downloaded VS2017(Enterprise) and tried with the sample unittest project, same exception here as well. – Somu Sep 27 '18 at 13:21

2 Answers2

1

Ok after several days of analysis , the mscorlib.fakes had to be updated to be able to overcome the COR_PROFILER/UnitTestingIsolationException related exception.

Below is the snapshot of the modified mscorlib.fakes , if you notice we had to stop the shims/stub framework from generating stubs for the tracing/profiling related , the exact reason why its not able to generate is still unclear , but after adding these lines in my mscorlib fake file , the shimsContext creation works fine.

<Fakes xmlns="http://schemas.microsoft.com/fakes/2011/">
  <Assembly Name="mscorlib" Version="4.0.0.0"/>
  <StubGeneration>
    <Remove FullName="System.Diagnostics.Tracing"/>
    <Remove FullName="System.Text.Encoding"/>
    <Remove FullName="System.Security.Cryptography" />
  </StubGeneration>
</Fakes>
Somu
  • 515
  • 1
  • 5
  • 12
  • Thanks to Rachael for the article that pointed in the correct direction. https://www.nwcadence.com/blog/shims-and-stubs-and-the-microsoft-fakes-framework – Somu Oct 29 '18 at 09:44
  • Link provided by Somu is no longer active – str8ball Jun 07 '21 at 15:37
  • Hi @str8ball , sorry tried searching for that article(link seems to have been moved) if a similar post is available on the internet but no luck. But for me updating the mscorlib fake file as suggested above fixed that issue, let me know if that works for you. – Somu Jun 08 '21 at 23:27
  • Hi @Somu, thanks for replying. I have seen other posts about manipulating the fakes profile for various reasons. The path I'm following is to set the environment variables to my local folder (copied from the Nuget). The part I haven't figured out is why it wants to find the dll pointer in the registry instead of my local folder. – str8ball Jun 09 '21 at 13:34
1

I had the same error message but for vstestconsole.exe from Visual Studio 2022 and with no Fakse for mscore lib.

So I find out I had to add '/Framework:.NETCoreApp,Version=v6.0' as comand line parameter to solve the exception.

Daniel W.
  • 938
  • 8
  • 21