问题描述
试图用 orleans 编写一个 hello world 程序,但我遇到了这个异常。
我正在使用 .net 5
Microsoft.Orleans.CodeGeneration.MSBuild nuget 包
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
}
解决方法
这个{this.GetPrimaryKey()}
应该改为{this.GetPrimaryKeyAsString()}