سؤال

I'm testing a trivial web role under Azure Compute Emulator and have overridden OnStart(), Run() and OnStop() methods in my class that derives from RoleEntryPoint.

OnStart() and Run() are called but OnStop() is not - I will either press "Stop debugging" in Visual Studio or close the browser window and the role will be terminated, but OnStop() is never called. I've checked - the override keyword is present in OnStop() definition.

That's not very convenient - it means I can't test my OnStop() outside a live cloud.

Can I somehow make Compute Emulator call OnStop() in my role?

هل كانت مفيدة؟

المحلول

I suspect (but I'm not sure), that if you open the compute emulator UI and "stop" the deployment there, OnStop() should be called.

نصائح أخرى

You can use csrun to update the configuration of a running deployment. When you give the command the instance will call the OnStop() method.

To update the ServiceConfigure:

  • Open the Azure SDK bin folder through the command line
  • Issue the command csrun.exe /update:{Deployment ID, just the number};{Path of the cscfg file}

In my Compute Emulator it would be:

  • csrun.exe /update:252;"D:\user\My Documents\Visual Studio 2010\Projects\CSM\CSC\bin\Debug\ServiceConfiguration.cscfg"

If you intentionally exit from the Run() method, I believe OnStop() should be called.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top