Embedd an executable

  • Thread starter Thread starter Johan
  • Start date Start date
J

Johan

Hi

I was wondering if it's possible to embedd a command-line executable into my
project and call it from there.

The way I'm running now is with an external exe-file and calling it with
System.Diagnostics.Process and it works just fine but it would be great if I
could embedd the exe-file into the project.

I know I could embedd it and extract it at runtime to a temporary file but I
would like it to stay embedded.

Anyone got an idéa?

Thanks,

/Johan
 
I know I could embedd it and extract it at runtime to a temporary file
but I would like it to stay embedded.

I'm just guessing, but I think you could do it if it is a .NET EXE (embed
as resource, get the manifest resource stream, create an appDomain, call
into it), but if its not .NET EXE then I doubt it.

-mdb
 
Hi Johan,

If the executable is a managed assembly, you can try it to embed it in your
main exe. At run-time, you get its stream of bytes from the embedded
resource and pass them to the System.Reflection.Assembly.Load(bytes) method
that takes an array of bytes as parameter. That gives you the assembly
loaded in memory and then you use reflection to create an instance of its
types and call its methods.

I have not tested it, just an idea.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
Hi

It's not an .NET EXE, It's written in C and I have the executable and a
source file so guess I can take the long road and try to port it to C#
instead.

/Johan
 
Back
Top