0

I am trying to launch an external exe from a web application (running on Visual Studio development server). When I run the code below from a console application it works fine, but when I run it from a web page the application crashes. I presume this must be a permissions issue, but have tried a few things and not been able to get it working.

      private void RunExe(string pythonOutputFileNameAndLocation)
      {

            var process = new Process { StartInfo = GetProcessStartInfo(pythonOutputFileNameAndLocation) };            

            // This is where the application crashes   
            process.Start();

            // ...do some more things here
       }


       private ProcessStartInfo GetProcessStartInfo(string pythonOutputFileNameAndLocation)
            {
                var startInfo = new ProcessStartInfo
                {
                    CreateNoWindow = true, 
                    UseShellExecute = false,
                    RedirectStandardOutput = true,
                    RedirectStandardInput = true,
                    FileName = _exeFileLocation,
                    WindowStyle = ProcessWindowStyle.Hidden,
                    Arguments = String.Format("--hideUI --runScript {0}", pythonOutputFileNameAndLocation)                
                };

                return startInfo;
            }

What I am asking is why this code would work from a console application, but not from visual studio web server?

I am using Windows 7 and Visual Studio 2010.

EDIT:

As requested here are the problem details being caught by Windows:

  Problem Event Name:   BEX
  Application Name:
  Application Version:  2.2.2.2909
  Application Timestamp:    507bf285
  Fault Module Name:    MSVCR100.dll
  Fault Module Version: 10.0.40219.325
  Fault Module Timestamp:   4df2be1e
  Exception Offset: 0008af3e
  Exception Code:   c0000417
  Exception Data:   00000000
  OS Version:   6.1.7601.2.1.0.256.48
  Locale ID:    2057
  Additional Information 1: c5a0
  Additional Information 2: c5a0d9e876212c0d3929ba8445f002dc
  Additional Information 3: 5e93
  Additional Information 4: 5e93e44f8aa24f99d37e055f533d1658

I can't debug the external application as I don't have the code from it. Also I don't have a stack trace as I am not getting an exception. The external process is just crashing.

Thanks

Martin Liversage
  • 104,481
  • 22
  • 209
  • 256
Ronnie
  • 1,059
  • 14
  • 27
  • What's the stack and exception for the crash? can you attach a debugger and add more details? – bryanmac Feb 11 '13 at 13:28
  • I suspect he might be running into security issues. A stack trace would help a lot. – Pete Garafano Feb 11 '13 at 13:32
  • Exception code 0xc0000417 is raised when a C runtime function is called with an invalid argument. This is almost always a bug in the code that made the call. Not infrequently induced by lax error checking. Clearly you cannot debug this without the source code, you'll need help from the author or vendor of the app. – Hans Passant Feb 11 '13 at 13:44

3 Answers3

0

Ronnie, you might be running into a UAC and security access issue. Try disabling UAC and trying again. Also, consider on a real webserver this process will be started with the ASP.NET or web user permissions. These accounts are limited on purpose for security reasons. This means the application you are trying to start may fail because it cannot access files it needs. For this reason starting an external exe from a web server is not recommended. However, you can check this stackoverflow question about running applications with admin credentials. How to run c# application with admin creds?

Community
  • 1
  • 1
Pete Garafano
  • 4,863
  • 1
  • 23
  • 40
0

Probably security issue with permissions but it would be best if you could give us some more details about the exception.

Have you tried running this on IIS and checking how it works there?

Dragan Radivojevic
  • 1,992
  • 2
  • 13
  • 14
0

The exception code c0000417 has the symbolic name STATUS_INVALID_CRUNTIME_PARAMETER. Googling for "python" and "STATUS_INVALID_CRUNTIME_PARAMETER" lead to various python issues around directory permissions. You can user Process Monitor to discover if there are any permission issues while trying to run your application.

Martin Liversage
  • 104,481
  • 22
  • 209
  • 256