2

I have two DLLs with separate code inside them, but with the same NAME and same VERSION. Neither of these can be changed. They are in two separate C# projects, which do not reference each other, but are instead class libraries loaded within the same Console app. I've got a small diagram listed below.

Flow chart

When running the app it seems to take one of these in compilation, seen in the output directory, and thus throws a reflective exception trying to call code from the other DLL in the code of the second class library. In Visual Studio, everything seems fine in the IDE - and references the contents of each DLL as different per library project.

I was wondering if there was any way to get this working without editing the DLLs at all, like a build step that I can set up easily, to ensure these DLLs aren't confused with each other, so to speak.

To clarify, many other questions on this platform question have different versions of the same named DLL. In this, identifiers like the name and version are identical - what's not, is the code inside each. I know this should never happen unless you're doing something really hacky.

Thanks in advance!

10
  • 1
    You will need to learn about Loading DLLs into a separate AppDomain Commented Nov 25, 2022 at 1:34
  • @JohnWu AppDomains seem to be obsolete in .Net Core (at least starting with NET 6). Commented Nov 25, 2022 at 2:09
  • In that case I have no clue how to do it. I'm upvoting your question. Commented Nov 25, 2022 at 3:04
  • If you're looking for some magic HintPath or something I'm pretty sure you're are not going to find it. You're breaking all the rules in the book because its what you need to do. This should never happen, why? Two DLLs same version, same name BUT completely different code?? An upvote for your certified Stack Overflow drawing skills tho :) Commented Nov 25, 2022 at 4:53
  • For .NET (Core) you have assembly load contexts: Managed assembly loading algorithm Commented Nov 25, 2022 at 11:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.