如果 grain 使用主键扩展功能,则不能使用 UniqueKey.PrimaryKeyToGuid 的重载
This overload of UniqueKey.PrimaryKeyToGuid cannot be used if the grain uses the primary key extension feature
尝试用 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()}
尝试用 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()}