HeartbeatActorServiceType is invalid and cannot be registered. Only ServiceTypes specified in the ServiceManifest can register.

If you try to register an actor within a Service Fabric service like this:

ActorRuntime.RegisterActorAsync((serviceContext, agentType) => new AgentService(serviceContext, agentType))
            .GetAwaiter()
            .GetResult();

but getting the following exception:

System.Fabric.FabricException: ‘Invalid Service Type’
Inner Exception: COMException: Exception from HRESULT: 0x80071C21

then in Event Log (Applications and Services Logs -> Microsoft-Service-Fabric -> Admin) you’ll see an entry like this:

StartRegister: HeartbeatActorServiceType is invalid and cannot be registered. Only ServiceTypes specified in the ServiceManifest can register.

This happens because by default service name is inferred from actor name, e.g. HeartbeatActor would produce HeartbeatActorServiceType. And your service is called differently, AgentService in my case. Hence the error.

To change the behavior, apply [ActorServiceAttribute] to the actor:

[ActorService(Name = nameof(AgentService))]
[StatePersistence(StatePersistence.None)]
class HeartbeatActor : Actor, IHeartbeatActor
{
}

That’s it, folks!

This entry was posted in Programming and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.