如何解决如果谷物使用主键扩展功能,则无法使用 UniqueKey.PrimaryKeyToGuid 的重载
试图用 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()}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。