tags:

views:

372

answers:

2

We have a WCF service that we recently switched from self-hosting to IIS-hosted. It needs to launch an executable using Process.Start(). This works fine when it's self-hosted, but when hosted in IIS, we get the error:

System.ComponentModel.Win32Exception: The system cannot find the file specified

We have the exe in both the bin directory and in the application root (next to the .svc file.) But, it can't seem to find the exe.

Any help would be appreciated. Thanks!

EDIT: I forgot to mention that we're launching using the following code: Process.Start("LeakingWrapper.exe");

FURTHER INFO: Unfortunately, we don't have the option to switch the exe to a dll, because it is wrapping a third-party library that leaks memory. So, we have to put it into its own process to ensure our long-running WCF service doesn't leak!

+1  A: 

Do you have the aspNetCompatibilityEnabled setting set to true? In that case, you'd have a HttpContext, which could try to use to call something like:

string exeFileName = HttpContext.Current.Server.MapPath("~/LeakingWrapper.exe")

Or: what if you specify the whole path to the EXE, e.g.

Process.Start("C:\yourServiceDir\bin\LeakingWrapper.exe")

Does that help at all??

Marc

marc_s
We ended up using your second suggestion and stored the full path in web.config, then passed it into Process.Start(). Thanks for the help!
GuyBehindtheGuy
A: 

marc_s answer is probably correct.

However, it could also be that the process cannont find the file because it does not have the rights to read the exe file.

Shiraz Bhaiji
I used Process Monitor to make sure it was not a permissions problem. w3wp.exe just couldn't find the executable!
GuyBehindtheGuy