2

I have the following dependency tree

  • MyFramework
  • DataAccess
  • Processor
  • Processor.Tests

Each assembly references on all of the ones above it. So Processor.Tests references Processor, DataAccess, and MyFramework. With the exception of ProcessorTests reference to Processor all references are through a private Nuget server.

There is an interface (IMessageLogger) in the DataAccess assemble that I need to mock. One of the methods in that interfaces has an argument of a type defined in MyFramework.

When I try to Mock.Create<IMessageLogger>() I get the following exception

System.IO.FileLoadException : Could not load file or assembly 'MyFramework, Version=2017.12.12.1, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)

None of my assemblies are strong named, but Telerik.JustMock is strong named, but it hasn't given me any trouble mocking any other interfaces so far.

Anyone have any idea how I might be able to work around this?

Jeremy Hutchinson
  • 1,975
  • 16
  • 26
  • `or one of its dependencies` - What does `MyFramework` reference as a dependency? – Nkosi Mar 30 '18 at 17:23
  • It references 20 other assemblies (some internal some public Nuget, some .Net Framework), some of those will of course reference other assemblies. Are you looking for something specific? Or are you thinking the name of an assembly might tip you off? – Jeremy Hutchinson Mar 30 '18 at 17:36
  • No. I am thinking on of the other referenced assemblies is causing a problem with the test project. – Nkosi Mar 30 '18 at 17:38
  • I just went through all of the references from the MyFramework project. Everything that is referenced there is also referenced from the Processor.Test, the versions match and the few assemblies with binding redirects match between all projects. – Jeremy Hutchinson Mar 30 '18 at 18:42
  • Aside from the standard stuff (Microsoft.CSharp, System, System.Data etc), we reference a handful of other internal packages from our private Nuget and the following 3rd party libraries: antlr.runtime, NewtonSoft.Json, Org.Metalis.Security, RestSharp, TopShelf and XSerializer – Jeremy Hutchinson Mar 30 '18 at 18:45
  • Can you check project's framework versions? Project framework version must not be lower than project's version which is used in project. For example, 'Processor' project's framework version is .Net 4.6.1, 'Processor.Tests' must not be lower than this framework. In this case you get error like this. May be this is your problem may be not :) – Adem Catamak Mar 30 '18 at 19:53
  • A quick look everything seems to be .Net 4.5, but should't allow lower versions, but not higher? I thought .Net 4.5 was a superset of .Net 4.0 etc and that it should only be a problem if one of the dependencies was 4.6.1. I'll dig in to each dependency in the chain Monday. – Jeremy Hutchinson Mar 31 '18 at 01:15

1 Answers1

0

It turns out the problem was that I had the Processor and Processor.Test projects were referencing version 2018.3.15 of the MyFramework assembly, but the DataAccess project was referencing an older version (2017.12.12.1).

Updated all of the projects to use the latest and everything is running again.

Jeremy Hutchinson
  • 1,975
  • 16
  • 26