6

I am trying to use the stack exchange MiniProfiler in my asp MVC project, but getting a really annoying error message in my view, where I am calling

@using StackExchange.Profiling

and

@MiniProfiler.RenderIncludes()

on the RenderIncludes line, VS complains that

The type 'MiniProfiler' exists in both 'MiniProfiler.Shared, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b44f9351044011a3' and 'MiniProfiler, Version=3.2.0.157, Culture=neutral, PublicKeyToken=b44f9351044011a3'

I already checked the (.csprroj) project file, and it only contains one element referencing MiniProfiler:

<Reference Include="MiniProfiler, Version=3.2.0.157, Culture=neutral, PublicKeyToken=b44f9351044011a3, processorArchitecture=MSIL">
  <HintPath>..\packages\MiniProfiler.3.2.0.157\lib\net40\MiniProfiler.dll</HintPath>
</Reference>

I also checked in packages.config and it also only has 1 reference to MiniProfiler:

<package id="MiniProfiler" version="3.2.0.157" targetFramework="net452" />

I cleaned the project and restarted Visual Studio but with no success. What is happening here?

Bassie
  • 9,529
  • 8
  • 68
  • 159
  • 2
    For anyone else finding this: it can also happen if you update MiniProfiler to v4 *but not all packages*. To resolve that, upgrade all packages to the same version. – Nick Craver Mar 18 '18 at 14:25
  • 1
    This happened to me when I tried upgrading MiniProfiler to version 4, and then rolled back to version 3. `MiniProfiler.Shared` was still in the `/bin` folder. Thank! – Kobi Jun 13 '18 at 05:23

1 Answers1

6

So I manageed to find the cause of this when I double-clicked on MiniProfiler under References in the solution explorer.

This opens up an object explorer in the main window, which was displaying some references which were not visible in the solution explorer (how annoying), including MiniProfiler.Shared.

So I checked the path for these, and they were in the bin folder. After physically deleting the files, my error went away.

Bassie
  • 9,529
  • 8
  • 68
  • 159