5

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!

3 Answers 3

3

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

1
  • 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! Sep 19, 2009 at 18:40
0

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.

1
  • I used Process Monitor to make sure it was not a permissions problem. w3wp.exe just couldn't find the executable! Sep 19, 2009 at 18:41
0

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>`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.