1

I have on Visual Studio Solution with multible projects. All projects are c# .net application with on exception. This one is called utility and builds to a class libary. Every Project references the utility project.

Is there a way that the dll created by the utility class is not build for every project separately and in one location?

Visual Studio Solution

Solution
 - Project 1 (references utility)
 - Project 2 (references utility)
 - Project 3 (references utility)
 - Project Launcher (references utility)
 - Project utility

Current Build Folder Structure

Main Folder
 - Launcher.exe
 - Utility.dll
 -> Project 1 Folder
    - 1.exe
    - Utility.dll
 -> Project 2 Folder
    - 2.exe
    - Utility.dll
 -> Project 3 Folder
    - 3.exe
    - Utility.dll

Wanted Build Folder Structure

Main Folder
 - Launcher.exe
 -> Project 1 Folder
    - 1.exe
 -> Project 2 Folder
    - 2.exe
 -> Project 3 Folder
    - 3.exe
 -> References Folder
    - Utility.dll

Edit: The applications won't run at the same time and do need to communicate to the same instance. Using a shared project sovled my issue. how-to-make-net-class-library-linkable-no-dll

  • If you need to share a .NET DLL you typically store it in the GAC (Global Assembly Cache) which is covered in the suggested duplicate – Stephen Kennedy Jul 03 '19 at 15:22
  • Another approach is to convert your library to a shared project - instead of getting a DLL the code is compiled in to your executables. – Stephen Kennedy Jul 03 '19 at 15:31

1 Answers1

0

Possible duplicate of: Can the same DLL data be shared by 2 different processes?

As you've stated in your current build structure: When two applications use a DLL, the DLL is not shared between them. Each application loads its own copy, and has it's own memory space and variables.

This is the normal behavior. If you want two applications to communicate and share data between them, you need to use some form of interprocess communication to "pass" the data back and forth. Windows Communication Foundation is a great option in this case.

Erskan
  • 108
  • 9
  • All applications won't run at the same time and don't need to communicate. Utility is a libary which provides stuff like logger class – CaptainLama Jul 03 '19 at 10:20
  • 1
    Okey I see. Maybe this can help you? [how-to-make-net-class-library-linkable-no-dll](https://stackoverflow.com/questions/47914887/how-to-make-net-class-library-linkable-no-dll) – Erskan Jul 03 '19 at 12:10
  • This helped and solved my issue – CaptainLama Jul 04 '19 at 07:31