Ambiguity in package links version

The project has several links to the Ninject library, which have their own version, and unit tests are not performed, error:

Message: System.IO.FileLoadException: Failed to load file or assembly "Ninject, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = c7192dc5380945e7" or one of its dependencies. The located assembly manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ---- System.IO.FileLoadException: Failed to load file or assembly "Ninject, Version = 3.2.0.0, Culture = neutral, PublicKeyToken = c7192dc5380945e7" or one of its dependencies. The located assembly manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

1- csproj file

<Reference Include="Ninject, Version=3.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
  <HintPath>..\packages\Ninject.3.2.2.0\lib\net45-full\Ninject.dll</HintPath>
</Reference>

2- packages.config

<package id="Ninject" version="3.2.2.0" targetFramework="net462" />

3- app.config

<dependentAssembly>
    <assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>

4- help folder -> expand -> right-click on the Ninject ->

Version: 3.2.0.0

5 NuGet Package Management → installed → enter image description here

It looks somehow in my project referencing versions 4.0.0.0 and 3.2.0.0. I only want a link to version 3.2.2.0.

how to do it?

what are the differences between these links?

+4
source share
4 answers

I know this is an old post, but I think this understanding will be very useful for troubleshooting.

, . - , , , , . , . nuget , , bin.

, /. , , .

ninject Ninject.Web.Common.WebHost, /. , bin.

+6

Ninject 3.3.3.0 ( v3.3.4)

(.csproj), web.config packages.config, .

  • Ninject NuGet .
  • " NuGet " Ninject .

, ... !

+1

, .

- Ninject 3.2.2.0.

3.2.2. package.config app.config 3.2.0.0. . . 3.2.2.0, 3.2.0.0. , , , .

, :

CSProj:

<Reference Include="Ninject, Version=3.2.0.0, Culture=neutral, PublicKeyToken=c7192dc5380945e7, processorArchitecture=MSIL">
  <HintPath>..\packages\Ninject.3.2.2.0\lib\net45-full\Ninject.dll</HintPath>
</Reference>

Packages.config:

<package id="Ninject" version="3.2.2.0" targetFramework="net452" />

App.config:

<dependentAssembly>
    <assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-3.2.0.0" newVersion="3.2.0.0" />
</dependentAssembly>
+1

Since I run Ninject inside the Window service, I had to install the ServiceName.exe.Config file to get the app.config information loaded correctly when my service starts.

<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
          <assemblyIdentity name="Ninject" publicKeyToken="c7192dc5380945e7" culture="neutral" />
        <bindingRedirect oldVersion="3.3.3.0" newVersion="3.3.4.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
0
source

Source: https://habr.com/ru/post/1687105/


All Articles