© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•12mo ago•
9 replies
aliser

Loading DLLs with same names

Hi!

I'm making a mod loader (.net 9), and I've encountered an issue when trying to load multiple mod files (dll files) with the same name but from different locations. They have different namespaces so I expected no collisions when loading them.

I was using
Assembly.LoadFrom
Assembly.LoadFrom
, and it worked fine for a single mod. But when I tried to load 2, I've got this error:
Could not load file or assembly 'Main, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Assembly with same name is already loaded
Could not load file or assembly 'Main, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Assembly with same name is already loaded

I've gathered this due to the assembly name being the same for different mods. This is done intentionally to make the mod development easier. There's still a difference in namespace naming between different mods.

I tried to switch to
Assembly.LoadFile
Assembly.LoadFile
(heard it can use the paths to differentiate between same-named dlls). But I started to get these errors:
Could not load file or assembly '0Harmony, Version=2.3.5.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
Could not load file or assembly '0Harmony, Version=2.3.5.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

0Harmony
0Harmony
is a dependency of a mod (both mods actually, but they each have it on their own). It doesn't load for some reason.

I tried messing with
AssemblyLoadContext
AssemblyLoadContext
and looking up solutions online, but it's a bit too advanced for me.

Please help 😭
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ EF Core 7 - FromSql join with same column names
C#CC# / help
3y ago
NativeAOT multiple Dlls
C#CC# / help
5w ago
Conflicting System dlls
C#CC# / help
16mo ago
Class with same name as namespace
C#CC# / help
2y ago