Reputation: 1368
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!
Upvotes: 5
Views: 6592
Reputation: 1904
To use the web service's path using HttpContext
you must include the following line in your web service's web.config
<configuration>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
</configuration>`
Upvotes: 0
Reputation: 65381
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.
Upvotes: 0
Reputation: 754408
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
Upvotes: 3