Beantwortet Application startup task failed with exit code 3.

  • Wednesday, May 02, 2012 10:28 PM
     
      Has Code

    I have a WorkerRole that just starts another Process as such:

    public override void Run()
            {
                ProcessStartInfo si = new ProcessStartInfo() { FileName = "service.exe", Verb = "runas" };
                System.Diagnostics.Process.Start(si);
                
    
                while (true)
                {
                    Thread.Sleep(10000);
                }
            }

    service.exe is a console app that is hosting a WCF Server instance that I should be able to connect to with my Client portion. This HAS to be a separate Process since its x86 based and uses a 32-bit COM dll. I am following what Microsoft has in the training course.

    I have added the service.exe, service.exe.config, the COM dll and the Interop dll for it to base directory of the project with "Build Action = None" and "Copy to Output Directory = Copy always" along with a batch .cmd file to register the COM component "Register.cmd" that has the following content:

    echo off
    regsvr32.exe /s "Engine.dll"


    Here is also my app.config for the WorkerRole project with entry to run the Register.cmd on startup

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <system.diagnostics>
        <trace>
          <listeners>
            <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                name="AzureDiagnostics">
              <filter type="" />
            </add>
          </listeners>
        </trace>
      </system.diagnostics>
      <startup>
        <Task commandLine="Register.cmd" executionContext="elevated" taskType="simple" />
      </startup>
    </configuration>

    This all works great in emulator, but fails to deploy with "Application startup task failed with exit code 3." in Azure dashboard in windows.azure.com. It seems like the registration of COM is failing from the message since startup is failing, but what is wrong?

    Any help will be appreciated (What is exit code 3? How can I make sure the script ran successfully, or its the cause? Any way to debug?)


    noorbakhsh حميد نوربخش




    • Edited by noorbakhsh Wednesday, May 02, 2012 10:29 PM
    • Edited by noorbakhsh Wednesday, May 02, 2012 10:31 PM
    • Edited by noorbakhsh Wednesday, May 02, 2012 10:34 PM
    •  

All Replies

  • Thursday, May 03, 2012 12:30 AM
     
     Answered

    What happens if you remote into the instance and try running register.cmd manually? Is there useful output that tells you what's going wrong? You could also try piping the output of regsvr32 somewhere in the startup task, e.g. "regsvr ... > log.txt 2> err.txt". Either way, your next step of debugging will probably involve remoting into the instance.

    Also, a complete side note, but I would strongly recommend starting the process and then doing proc.WaitForExit() instead of the while loop. That way if the process dies, your role instance will die too (and thus get restarted automatically by Windows Azure). As you've written it, if service.exe dies, your role instance will appear to be healthy and just sit there doing nothing.

    • Marked As Answer by noorbakhsh Thursday, May 03, 2012 5:40 PM
    •  
  • Thursday, May 03, 2012 3:58 AM
     
     

    Thanks Steve, will give it a try with the remote and try your suggestion.

    I read somewhere today that 'code 3' is a path not found error message, but I also tried "%~d0Engine.dll" and "%~d0\Engine.dll" and both had same error message.


    noorbakhsh حميد نوربخش

  • Thursday, May 03, 2012 3:25 PM
     
     Answered Has Code

    Steve,

    I remoted in and tried to run the Register batch, and even an elevated command myself. Even though I was in the Engine.dll directory, both running the batch and direct regsvr32 call failed with:

    The module "Engine.dll' failed to load. Make sure the binary is stored at the specified path or debug it to check for problems with the binary or dependent .DLL files. The specified module could not be found.

    Well since this is a test project and I just made a simple Engine.dll that does add/subtract and everything works fine on my machine, I thought that the issue MUST be the dependencies. The Engine.dll is a Visual C++ ATL (ActiveX) project with an ATL Simple Object in it. I needed the vcredist_x86 (since Engine.dll is 32 bit - and it is 32 bit on purpose to mimic the real one we are going to deploy), so I added thevcredist_x86.exe to the project and changed my Register.cmd to:

    echo off
    "%~dp0vcredist_x86.exe" /q /norestart
    regsvr32.exe /s "%~dp0MathEngine.dll"

    ANd this runs fine when ran from RDP console. But now I am getting 'Unhandled Exception', so at least now I know the reistration is working and trying to look into next step.

    Thanks Steve for sending me on the right path.

    Edit: By the way for anyone interested, if you modify the cmd batch from Visual Studio, it will convert it to UTF-8 that will see an extra character at the beginning that will cause the first line to fail, so be aware (it needs to be ANSI)


    noorbakhsh حميد نوربخش



    • Edited by noorbakhsh Thursday, May 03, 2012 5:39 PM
    • Marked As Answer by noorbakhsh Thursday, May 03, 2012 5:40 PM
    • Edited by noorbakhsh Thursday, May 03, 2012 5:44 PM
    •