1

I'm creating a wrapper for WkHtmlToPdf. This executable parses html and returns a pdf document as the name suggests.

You call this as follows: wkHtmlToPdf.exe www.example.com "C:\Results\Result.pdf".

The executable also comes with a few dlls.

Is there an easy solution to load the .exe into memory and call it?

Currently the code I wrote takes the .exe and the .dlls as resources, saves them to the Temp directory and calls them via command line. This current method is working nicely, but the step of saving them to the temp directory to call them sounds unnecessary. Surely there is a something like SomeReflectionMethod.Invoke(Resources.wkHtmlToPdf.exe, "www.example.com \"C:\Results\Result.pdf\"").

I have found similar questions, but am finding it difficult seeing the similarities between my specific question (and henceforth the accuracy of the provided answer).

I also have run into a few scary solutions as defined here.

tshepang
  • 12,111
  • 21
  • 91
  • 136
SamuelKDavis
  • 1,033
  • 1
  • 7
  • 14
  • [Process.Start()](http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx) – Robert Harvey Sep 04 '13 at 20:21
  • Native DLL's cannot be loaded from memory (at least not for p/invoke). – leppie Sep 04 '13 at 20:25
  • Hello Robert, I would like to use Process.Start but am not sure how to call an in memory executable and allow it to see the .dlls – SamuelKDavis Sep 04 '13 at 20:43
  • Hello VcsJones. There was no real solution provided, just saying it would be difficult to recurse through the dll dependencies that have dll dependencies. I only have 5 dlls and one .exe. – SamuelKDavis Sep 04 '13 at 20:44
  • Storing DLLs into an EXE is very common. The EXE is normally called setup.exe, you no doubt used one before. Most every Windows user expects one. – Hans Passant Sep 04 '13 at 23:37
  • I would use ILMerge and merge the dll's with the .exe. Could you possibly provide an answer on how to call this new merged .exe in memory though? – SamuelKDavis Sep 05 '13 at 01:10

0 Answers0