1

I've got an assembly in my project that I'm using throughout my project without problems. There is however one class which throws an error when trying to use the DLL.

"Could not load file or assembly XXX or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference."

The version of my DLL is 1.0.0.1 but the class seems to be looking for 1.0.0.0. I have checked everywhere and cannot find a reference to 1.0.0.0 anywhere.

I ran fuslogvw to see where the conflict is happening and looks like:

=== Pre-bind state information ===
LOG: DisplayName = XXXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=dcd25968a59ae23f
 (Fully-specified)
LOG: Appbase = XXXX
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = XXXX
Calling assembly : EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.

Why is EntityFramework trying to call my DLL and why would it be looking for a lower version. Could i perhaps do a DLL redirect somewhere to fix this?

Thanks


EDIT After in depth investigation it seems like there was an additional EF package (with a lower version number than the current one). I uninstalled all packages, had to manually delete them from the package folder as well, and re installed the latest. Together with the DLL redirect, this seems to have solved the problem

Zee18
  • 425
  • 2
  • 5
  • 11
  • 1
    Did you check your .config file ? – dotnetstep Oct 24 '14 at 08:19
  • 1
    Although i think the problem should be fixed elsewhere with 'the correct means' (what ever they may be). You could always do a assembly policy redirect from 1.0.0.0 to 1.0.0.1. – Marvin Smit Oct 24 '14 at 08:26
  • I have tried a redirect but this doesnt seem to work. As soon as I use EF on the context it breaks – Zee18 Oct 24 '14 at 09:46

1 Answers1

0

Even if it is looking for an older version, you can still redirect to a newer assembly version with following configuration. EF would have been compiled with an older version, so it is trying to load it

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <dependentAssembly>
            <assemblyIdentity name="myAssembly"
                              publicKeyToken="32ab4ba45e0a69a1"
                              culture="neutral" />
            <bindingRedirect oldVersion="1.0.0.0"
                             newVersion="2.0.0.0"/>
         </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>

Check the following links:

MSDN Binding Redirect

Assembly Redirection - Stack overflow

Community
  • 1
  • 1
Mrinal Kamboj
  • 11,300
  • 5
  • 40
  • 74
  • Thanks for your response, I must add that i added a redirect to the config for the problematic project however the problem persists. – Zee18 Oct 24 '14 at 09:47
  • I am assuming you are doing in Web.Config / App.exe.config. One thing check the EF installation folder, make the change in its configuration file, since is is not your application but EF which is internally loading the dll, so it will keep trying the older version, since redirect is in your application. – Mrinal Kamboj Oct 24 '14 at 09:58
  • OK. Where would I do this in the EF folder. Its a normal nuget installation. – Zee18 Oct 24 '14 at 10:15
  • I do not have EF installed need to check, meanwhile check these links, though little different thay talk about loading the correct EF version as the application itself might be loading an older version of EF thus causing the issue: http://stackoverflow.com/questions/11749175/could-not-load-file-or-assembly-entityframework-after-downgrading-ef-5-0-0-0 http://stackoverflow.com/questions/17042237/errorcould-not-load-file-or-assembly-entity-framework-4-4-0-0-on-opening-applic – Mrinal Kamboj Oct 24 '14 at 10:31