Skip to content

Could not load file or assembly 'Unity.Abstractions, Version=5.11.2.0' #34

@bairog

Description

@bairog

I have a dll 'A' which is using latest Unity.Container(5.11.11.0), Unity.Abstractions(5.11.7.0) and Unity.Configuration(5.11.2.0). It has a method which is using following code to load dynamically in container (that container is exposed):

container = new UnityContainer();
var unitySection = configuration.Sections["unity"] as UnityConfigurationSection;
container.LoadConfiguration(unitySection);

Another dll 'B' using only Unity.Container(5.11.11.0), Unity.Abstractions(5.11.7.0) and performs class creations (and it uses dll 'A'):
IMyInterface class = container.Resolve<IMyInterface>();

Once I try to execute a test application (that uses dll 'B') I receive following exception:

System.IO.FileLoadException: Could not load file or assembly 'Unity.Abstractions, Version=5.11.2.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Very strange, because I compile both libraries with Unity.Abstractions(5.11.7.0).
As a workaround I'm using AppDomain.CurrentDomain.AssemblyResolve event and load appropriate library directly.

But what is the root of this problem? Howto get rid of it?

P. S. I use Visual Studio 2019 16.9.0 and my modules are compied for .NET Framework 4.0.

Can be related to #20

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions