G
Guest
I had originally written a program as a c# console application. The program
used a reference that I wrote in c++. Later I was told to re-write the
application as a windows service. When the service would start up, as soon as
it accessed the reference (by instantiating a class within the reference),
the service would crash. In the event viewer I saw that it throw a
System.IO.FileNotFoundException saying that the c++ reference was missing
(even though it was in the same directory as the .exe). I decided to write a
windows service that would simply launch the console application. In the
“OnStart†method I called the win32 API CreateProcess (which I P/Invoked).
When the service started it launched the console application successfully,
the console application then as soon as the reference was "used" by the
console application the console application crashes saying
File.IO.FileNotFoundException. As sanity check first I ran the console app by
itself and it ran just fine. Then I created a second c# console application
and in the main I used the exact same code from the “OnStart†of the afore
mentioned service (CreateProcess api) and it launched my original program
just fine.
Why is there a difference if I use CreateProcess from a c# service vs. c#
console application? Also isn't a service simply a console application that
interacts with service control manager?
used a reference that I wrote in c++. Later I was told to re-write the
application as a windows service. When the service would start up, as soon as
it accessed the reference (by instantiating a class within the reference),
the service would crash. In the event viewer I saw that it throw a
System.IO.FileNotFoundException saying that the c++ reference was missing
(even though it was in the same directory as the .exe). I decided to write a
windows service that would simply launch the console application. In the
“OnStart†method I called the win32 API CreateProcess (which I P/Invoked).
When the service started it launched the console application successfully,
the console application then as soon as the reference was "used" by the
console application the console application crashes saying
File.IO.FileNotFoundException. As sanity check first I ran the console app by
itself and it ran just fine. Then I created a second c# console application
and in the main I used the exact same code from the “OnStart†of the afore
mentioned service (CreateProcess api) and it launched my original program
just fine.
Why is there a difference if I use CreateProcess from a c# service vs. c#
console application? Also isn't a service simply a console application that
interacts with service control manager?