Search code examples
orleans

This overload of UniqueKey.PrimaryKeyToGuid cannot be used if the grain uses the primary key extension feature


trying to write an hello world program with orleans and I am getting this exception.

I am using .net 5

the Microsoft.Orleans.CodeGeneration.MSBuild nuget pakage

InvalidOperationException: This overload of UniqueKey.PrimaryKeyToGuid cannot be used if the grain 
   uses the primary key extension feature.
   at Orleans.Runtime.UniqueKey.ThrowIfHasKeyExt(String methodName)
   at Orleans.Runtime.UniqueKey.PrimaryKeyToGuid()
   at Orleans.Runtime.GrainId.GetPrimaryKey()



var result = await _clusterClient.GetGrain<IHelloWorldGrain>("leke").SayHelloToAsync(name);

public class HelloWorldGrain : Grain, IHelloWorldGrain
{
    private int _invocationCount = 0;

    public Task<string> SayHelloToAsync(string name)
    {
         return Task.FromResult($"Hello {name} from {this.GetPrimaryKey()} - I have said hello {_invocationCount++} times.");
    }
}


public interface IHelloWorldGrain: IGrainWithStringKey
{
    Task<string> SayHelloToAsync(string name);enter code here
}

Solution

  • This {this.GetPrimaryKey()} should be changed to {this.GetPrimaryKeyAsString()}