服务结构调试

Service Fabric Debugging

当我在调试模式下尝试从 VS 运行 SF 服务时,我得到以下信息:

An attempt was made to upgrade the application but the application's version has not been changed. Be sure to update the version in the application manifest prior to upgrading.

我必须在 SF explorer 中手动删除此服务。有没有办法以某种方式跳过此删除步骤,以便正在调试的服务只是 'overwrites' 旧服务?

您可以将调试器附加到已部署的应用程序进程。转到调试 -> 附加到进程。您可以选择多项服务。注意管理员模式下Visual Studio需要运行。

如果要调试服务的启动代码,请使用 Debugger.Launch()。该方法会阻塞调用代码并提示你选择调试器,你可以选择一个运行的VS实例。不幸的是,有一个错误,VS2017 没有作为选项出现。或者,您可以在启动时调用 Thread.Sleep(<duration>) 并快速附加调试器,最后一个选项始终有效。

这是因为应用程序调试模式的配置设置不正确。 该设置可能设置为 停止调试时将应用程序 保留在 Service Fabric 中,这样,在第一次部署后,应用程序将保留 运行 部署到 SF 的旧代码.

您的其他选项设置为 删除应用程序刷新应用程序

作为参考,您的选择是:

Application Debug Modes

  • Refresh Application This mode enables you to quickly change and debug your code and supports editing static web files while debugging. This mode only works if your local development cluster is in 1-Node mode. This is the default Application Debug Mode.
  • Remove Application causes the application to be removed when the debug session ends.
  • Auto Upgrade The application continues to run when the debug session ends. The next debug session will treat the deployment as an upgrade. The upgrade process preserves any data that you entered in a previous debug session.
  • Keep Application The application keeps running in the cluster when the debug session ends. At the beginning of the next debug session, the application will be removed.

This doc 详细解释。