从服务结构应用程序中读取 ApplicationManifest.xml 的服务版本

Read service versions from ApplicationManifest.xml from within a service fabric application

服务结构的包可以包含多个服务。它们的版本号记录在包的 ApplicationPackageRoot/ApplicationManifest.xml 中:

...
<ServiceManifestImport>
 <ServiceManifestRef ServiceManifestName="VotingDataPkg" ServiceManifestVersion="1.0.29" />
</ServiceManifestImport>
<ServiceManifestImport>
  <ServiceManifestRef ServiceManifestName="VotingWebPkg" ServiceManifestVersion="1.0.29" />
</ServiceManifestImport>
...

问题:是否可以从包中的一项 .NET 服务中读取此版本信息?

我想让包中的web服务从ApplicationManifest.xml读取版本信息,并呈现在他的网页上。

您可以使用在 "runasync" 方法中提供给您的 servicecontext 并调用 context.CodePackageActivationContext 并向下钻取包版本。