0

Is there a way to keep any DLLs needed for my Visual C# program (such as SQLite) inside the actual EXE so it doesn't require the files to be present?

If not, can anyone show me how to make a wrapper for my program (independent of .NET, so maybe C++?) to copy/load required files to the working directory before starting the program itself.

What I intend to end up with is a single EXE file that can be deployed anywhere and set itself up like a transformer. All it requires is the following criteria:

  • SQLite is present
  • OpenHardwareMonitorLib is present
  • .NET 2.0 is installed (if not, offer install with redistributable package)
Chris Watts
  • 6,197
  • 7
  • 49
  • 98

4 Answers4

2

Microsoft provide a tool for merging DLLs. It's called ILMerge.

It doesn't always work, I believe certain things can cause problems. But it's definitely the easier option!

Alexander R
  • 2,468
  • 24
  • 28
1

If the problem is redistribute only one file, you can create a "installer" exe, that unpack all your dependencies (from executable content). If you don't want to leave all dlls in your production environment, you can merge all IL code in the main executable. you can use ILMerge (but it's not the only product that can do this)

AndreaCi
  • 809
  • 1
  • 9
  • 22
0

You can merge the dependencies into the main executable. After your build completes you run an additional tool that combines the IL code into a single assembly.

ILMerge can do this but is a bit cumbersome to use.

Some (proprietary) tools can do this as well. I know of at least one obfuscator (DeepSea) that can do this. DeepSea also allows you to specify what you want to include and what types you want to expose from the resulting assembly.

Full disclosure: I know the guys that build DeepSea Obfuscator.

Marnix van Valen
  • 13,265
  • 4
  • 47
  • 74
0

I guess you could embed the target assemblies as resources and then unpack them in some custom assembly resolution code?

Edit: there's an example of this here: Embedding assemblies inside another assembly

Community
  • 1
  • 1
Ian Gilroy
  • 2,031
  • 16
  • 14