0

I have a .NET 5 console application.

It didn't have a direct reference from the main exe to other class library projects.

However during runtime, it dynamically loads those DLLs and uses methods inside it, so the DLLs are required but I don't want to make a direct project reference within Visual Studio.

Since there is no direct reference from the main executable to these external DLLs, will the DLLs be merged if I use single-file deployment in .NET core?

If no, then what is a way to merge 4 DLLs, to 1 DLL (not 1 executable), so that I can have 1 executable & 1 DLL?

Ermiya Eskandary
  • 9,664
  • 3
  • 14
  • 25
Sangeeth Nandakumar
  • 1,185
  • 1
  • 9
  • 18
  • 1
    [How do I merge multiple .NET dlls?](https://stackoverflow.com/questions/1829531/how-do-i-merge-multiple-net-assemblies-into-a-single-assembly) – John Wu May 21 '21 at 07:14
  • My question is specific about direct project references and references loaded dynamically or using reflection – Sangeeth Nandakumar May 21 '21 at 07:16
  • Have you considered a [single file application](https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file)? and *why* don't you want a direct project reference? (since that is the simplest option, understanding why would be useful) – Marc Gravell May 21 '21 at 07:19
  • My application is architectured to receive a customer name claim from the JWT token during wuthentication. Based on this customer claim I want to identify and load dlls specific to those customers. I can have 100s or customers. I cannot add all customer dlls directly. So I find dll associated with a customer and loads it – Sangeeth Nandakumar May 21 '21 at 07:22
  • Now my requrement is. For a single customer I'm currently loading 4 dlls. I would like to merge these 4 dlls and load as a single dll – Sangeeth Nandakumar May 21 '21 at 07:24
  • Why do you need to use different assemblies? If only difference is names and images, than you can change only resources, but not entire assemblies. Once you have 100 customers, you're going to manage 400 libraries with almost same code? – JL0PD May 21 '21 at 11:41
  • It's not same code. Every client's logic is different. If I have 100 clients and each client requires 4 dlls to load. I cannot add a project reference to 400 dlls from my main exe. So I need to use dynamic dll loading using Assembly.LoadFile() and use reflection to work. As I mentioned, I would like to merge 4 dlls of a specific client to 1 (while I cannot directly reference those 4 dlls to my main exe to make use of .NET Core Single file deployment) – Sangeeth Nandakumar May 21 '21 at 11:46
  • Does this answer your question? [How do I merge multiple .net assemblies into a single assembly?](https://stackoverflow.com/questions/1829531/how-do-i-merge-multiple-net-assemblies-into-a-single-assembly) – Toni Oct 11 '21 at 11:59

0 Answers0