Search code examples
c#dllcompiler-errors

Where does CS0012 get its information from?


I have a C# application, based on version 84 of a certain DLL.

I have downgraded that DLL and now I'm using version 83. I have done this by replacing the following line in the .csproj file:

<!-- <Reference Include="Firmware.Internal, Version=1.0.84.1,
                             Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\Product.Core.22.1.25.3\lib\Firmware.Internal.dll
  </HintPath>
  <Private>False</Private>
</Reference> -->
<Reference Include="Firmware.Internal, Version=1.0.83.1, Culture=neutral,
           PublicKeyToken=..., processorArchitecture=MSIL">
  <HintPath>..\packages\Product.Core.16.12.6.1\lib\Firmware.Internal.dll
  </HintPath>
  <Private>False</Private>
</Reference>

This seems not to work, because of the following line in my source code:

Firmware.Internal.InternalGroup dockInternal = ...

The error message is:

The type 'InternalGroup' is defined in an assembly that is not referenced. You must add a reference to assembly 'Firmware.Internal, Version=1.0.84.1, Culture=neutral, PublicKeyToken=null'.

This is correct indeed: for version 84 this was working, and for version 83 this is not, so I should upgrade to version 84 in order to make it work.

Question: how does the compiler know that? I have removed the reference to version 84, so how can the compiler know that, in order to access that InternalGroup, version 84 is the one to be used (why not 85, 86, 136, ...)?

Remark: I have just deleted the commented lines (<!-- ... -->)in the *.csproj file and the result is equal, so the compiler is definitively not getting that information from that comment.

Edit:
P.s.:
I've just deleted the "bin" and the "obj" directories, no differences, so the information is not found in some lingering old compiled binaries neither.


Solution

  • You still may have a reference to version 84 in other projects inside the solution. Check if it is the case, downgrade all projects and rebuild all.