0

I have 2 solutions.

  1. Main

Which builds an assembly: Main.DomainTypes.dll (this will get packaged as a nuget package)

  1. External

Which builds an assembly: External.EventTypes.dll (this is also packaged as nuget package)

External.EventTypes.dll references Main.DomainTypes.dll via it's nuget package.

Now, some code has been added to Main, that references External.EventTypes (which therefore also references Main.DomainTypes).

When I run Main, it throws a FileNotFound exception, because it is trying to load the version of DomainTypes referenced by External.EventTypes, instead of the version it has just built.

I'm guessing that Main tries to load the highest version number referenced, which is the version in the nuget, not the version it has just built, except the version on disk IS the one just built, not the one referenced.

E.g., the nuget version of Main.DomainTypes referenced by External.EventTypes is 1.0.123, but the version of Main.DomainTypes just built doesn't yet have a package number, so defaults to 1.0.0

How can I get Main to load the local version, and not the nuget version?

I realise I could remove the circular reference by (re)defining the DomainTypes in external, but I'd rather not.

Neil
  • 11,059
  • 3
  • 31
  • 56
  • Sounds like you need to work on your project design. Perhaps pull the shared code into a third library which they can both reference. – Ibrennan208 Jun 29 '22 at 16:59
  • Does this answer your question? [Circular dependencies](https://stackoverflow.com/questions/2052579/circular-dependencies) – Ibrennan208 Jun 29 '22 at 17:00
  • This may help if you would rather go that route: https://stackoverflow.com/questions/1316518/how-did-microsoft-create-assemblies-that-have-circular-references#1316569 – Ibrennan208 Jun 29 '22 at 17:01
  • @Ibrennan208 It's not really a circular dependency in the way you suggest. The answer lies in how .NET loads the latest version of the assembly. – Neil Jun 30 '22 at 11:21

0 Answers0