- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遇到了一个问题,我的部署循环通过回收。来自 Visual Studio:
“在更新或升级操作期间,角色实例被回收了一定的次数。这表明您的服务的新版本或您在配置服务时提供的配置设置阻止了角色实例的运行。最可能的原因是这是因为您的代码引发了未处理的异常。请考虑修复您的服务或更改您的配置设置,以便角色实例不会引发未处理的异常。然后开始另一个更新或升级操作。在您开始另一个更新或升级操作之前,Windows Azure 将继续尝试将您的服务更新到您提供的新版本或配置”
我的问题:捕获异常的最佳方法是什么?我对 C# 有点陌生。我的 onStart 的精简版本,以防有帮助:
public override void Run()
{
// This is a sample worker implementation. Replace with your logic.
Trace.WriteLine("WorkerRole1 entry point called", "Information");
while (true)
{
Thread.Sleep(10000);
Trace.WriteLine("Working", "Information");
}
}
public override bool OnStart()
{
// Set the maximum number of concurrent connections
ServicePointManager.DefaultConnectionLimit = 12;
// Retrieve storage account from Connection String
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create blob client
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// retrieve reference to container (blob resides within container)
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
// create container if it doesn't already exist
container.CreateIfNotExist();
// make container public *temp*
container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });
// Retrieve references to required blobs
CloudBlob batch = container.GetBlobReference("batch.bat");
// Download batch file
using (var fileStream = System.IO.File.OpenWrite(@"C:\batch.bat"))
{
zip.DownloadToStream(fileStream);
}
// run batch file
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = "C:\\batch.bat";
proc.StartInfo.RedirectStandardError = false;
proc.StartInfo.RedirectStandardOutput = false;
proc.StartInfo.UseShellExecute = false;
proc.Start();
proc.WaitForExit();
return base.OnStart();
}
}
}
如果有帮助的话,这里是来自 RDP 的堆栈跟踪:
Stack:
at System.IO.__Error.WinIOError(Int32, System.String)
at System.IO.FileStream.Init(System.String, System.IO.FileMode, System.IO.FileAccess, Int32, Boolean, System.IO.FileShare, Int32, System.IO.FileOptions, SECURITY_ATTRIBUTES, System.String, Boolean, Boolean)
at System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, Int32, System.IO.FileOptions, System.String, Boolean)
at System.IO.FileStream..ctor(System.String, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare)
at System.IO.File.OpenWrite(System.String)
at WorkerRole1.WorkerRole.OnStart()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleType)
at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<InitializeRole>b__0()
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
最佳答案
我的博文Printf("HERE") in the Cloud可能有帮助。本质上,将整个事情包装在 try/catch 中并记录错误。
关于azure - 在 Azure 辅助角色的 onStart 方法中捕获异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11143280/
MMuzammil: MainActivity:in onCreate MMuzammil: FirstFragment:in onAttach MMuzammil: FirstFragment:in
使用WebRole.cs配置IIS时,建议调用base.OnStart()的方式是什么? public class WebRole : Microsoft.WindowsAzure.ServiceRu
我有一个 Ruby on Rails 应用程序,需要在 Azure 辅助角色中找到一个位置。 我目前使用批处理文件自动部署应用程序 - 该文件获取 apache 和 ruby 安装程序,运行它们,
我有一个 Ruby on Rails 应用程序,需要在 Azure 辅助角色中找到一个位置。 我目前使用批处理文件自动部署应用程序 - 该文件获取 apache 和 ruby 安装程序,运行它们,
我正在尝试实现一个非常简单的服务示例。用户通过 EditText 输入值并单击计算按钮。 Calculate 按钮触发一个服务,该服务执行一些计算并将结果发送回另一个 EditText 框。如果我使用
这个问题在这里已经有了答案: Android activity life cycle - what are all these methods for? (9 个回答) 关闭 9 年前。 关于Act
我已经阅读了关于 onResume() 和 onStart() 的文档,但我仍然不明白的一件事是 onResume() 在没有 onStart() 之前被调用? 最佳答案 请引用Android Act
我有这个 MainActivity,它会在我启动应用程序时启动,我知道只有这样 onCreate 才会被调用,然后 onStart 才会被调用。无论如何要知道是否调用了 onStart,而不先调用 o
我想节省countDownTimer开始工作的时间,有没有类似onStart()的方法? timeToDirectAnswer = new CountDownTimer(25000, 1000) {
我正在尝试了解 Android Activity 生命周期。为此,我创建了 Activity,其中覆盖了所有生命周期方法(onCreate、onStart、onRestart、onResume、onP
我是 android 开发的新手,我想为我的应用程序创建一个小部件。不幸的是我无法让它工作。我希望我的小部件启动服务。该服务应包含所有逻辑,例如根据内部存储文件的数据读取更新文本字段。我必须每分钟更新
我查看了关于堆栈溢出的另一个线程(来源:Difference between onCreate() and onStart()?)该线程将 onStart() 方法描述为“当 Activity 对用户
长话短说有没有人有任何例子说明 useAnimatedGestureHandler 的正确泛型是什么? 问题: 我正在关注 this Reanimated 2 手势动画教程。有这个例子: //...
在基于 NetBeans Platform 7.2 的应用程序中,可以用这段代码替换 ModuleInstall 类: import org.openide.modules.OnStart; impo
我正在.net 2.0 中编写 Windows 服务。 我应该在 OnStart() 内做什么如果出于某种原因我不希望我的服务启动的方法?我可以直接调用Stop()吗?基类的方法(ServiceBas
我的 Azure 解决方案中有一个简单的 WebRole 类: public class WebRole : RoleEntryPoint { public override bool OnS
当我启动 Play 服务器时,我只需要运行一些代码。使用 GlobalSettings.OnStart() 时,我注意到代码仅在对服务器的第一个 (http) 请求之后执行。知道如何在服务器启动后和发
这个问题在这里已经有了答案: Difference between onCreate() and onStart()? [duplicate] (2 个回答) 8年前关闭。 我一直想知道 onStar
我在 SwiftUI for MacOS 中使用 TapGesture。 TapGesture 仅在 TouchInsideOut 上被识别事件,当再次释放压力。我想在触地得分时调用一个 Action
在升级部署的情况下,OnStart 是否会从 WebRole.cs 调用? 最佳答案 http://msdn.microsoft.com/en-us/library/microsoft.windows
我是一名优秀的程序员,十分优秀!