Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

591
Visualizações
Error: Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.0.0.0

I get this error:

Could not load file or assembly 'Microsoft.Practices.ServiceLocation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

How do I resolve this with an assembly redirect binding, if I already have another existing version of Microsoft.Practices.ServiceLocation in my project?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

One method is to recompile all NuGet packages to use the same version of Microsoft.Practices.ServiceLocation. At a pragmatic level, this just isn't practical: we need an easier method.

A better method is to use an assembly binding redirect. This works very nicely, if the interface is the same. This solution is tried and tested, and is running in production in a number of FTSE companies.

This is what the app.config looks like:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.2.0.0" newVersion="1.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Adjust the target version to whatever version you already have, which is typically 1.2.0.0 or 1.3.0.0.

The PublicKeyToken must match the target assembly. You can extract it using the following command:

sn.exe -T assembly.dll

Example:

C:\test>"C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64\sn.exe" -T  C:\svn\lib\TargetDll.dll

Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.17929
Copyright (c) Microsoft Corporation.  All rights reserved.

Public key token is ac3efa7c033c2bd5
c:\test>

For other ways of obtaining the PublicKeyToken, see Getting the PublicKeyToken of .Net assemblies.

The PublicKeyToken does not change with the assembly version, e.g. its the same if the assembly is v1.0.0.0 or v2.0.0.0.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda