Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在RunAsync抛出中生成参与者”;接口id';1830616258';不是由对象';CustomActorService.InternalCustomActorService'&引用;_C#_Azure Service Fabric_Service Fabric Actor - Fatal编程技术网

C# 在RunAsync抛出中生成参与者”;接口id';1830616258';不是由对象';CustomActorService.InternalCustomActorService'&引用;

C# 在RunAsync抛出中生成参与者”;接口id';1830616258';不是由对象';CustomActorService.InternalCustomActorService'&引用;,c#,azure-service-fabric,service-fabric-actor,C#,Azure Service Fabric,Service Fabric Actor,我遵循中的建议,在服务开始时产生几个角色。我有一个自定义ActorService子类,具有以下RunAsync覆盖: internal sealed class InternalCustomActorService : ActorService { protected async override Task RunAsync(CancellationToken cancellationToken) { await base.RunAsync(cancellationToken);

我遵循中的建议,在服务开始时产生几个角色。我有一个自定义ActorService子类,具有以下RunAsync覆盖:

internal sealed class InternalCustomActorService : ActorService
{
  protected async override Task RunAsync(CancellationToken cancellationToken)
  {
    await base.RunAsync(cancellationToken);

    for(int i = 0; i < 10; i++)
    {
      ICustomActor proxy = ActorProxy.Create<ICustomActor>(new ActorId(i));
      await proxy.StartAsync();
    }
  }
...
示例项目位于GitHub上

我的问题是:我做错了什么

编辑:我尝试添加额外的
BootstrapperService
无状态服务,并从那里在
BootstrapperService.RunAsync
中生成参与者:

protected override async Task RunAsync(CancellationToken cancellationToken)
{
  await base.RunAsync(cancellationToken);
  await Task.Delay(10000);

  for (int i = 0; i < 10; i++)
  {
    ICustomActor proxy = ActorProxy.Create<ICustomActor>(new ActorId(i));
    await proxy.StartAsync();
  }
}
受保护的覆盖异步任务RunAsync(CancellationToken CancellationToken)
{
wait base.RunAsync(cancellationToken);
等待任务。延迟(10000);
对于(int i=0;i<10;i++)
{
ICustomActor proxy=ActorProxy.Create(新ActorId(i));
等待proxy.StartAsync();
}
}

但是,调用
proxy.StartAsync()
会引发与上述
InternalCustomActorService.RunAsync
中完全相同的异常。

从自定义actor服务中删除以下代码:

     protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners() 
 { 
   var remotingListener = new ServiceReplicaListener(context => this.CreateServiceRemotingListener(context)); 
   return new ServiceReplicaListener[] { remotingListener }; 
 } 
protectedoverride IEnumerable CreateServiceReplicaListeners()
{ 
var remotingListener=new serviceremplicastener(context=>this.CreateServiceRemotingListener(context));
返回新的ServiceReplicaListener[]{remotingListener};
} 

这将删除基本ActorService正在设置的ActorMotingListener。如果要添加其他侦听器,请调用基本的CreateServiceReplicaListeners方法,获取侦听器,然后添加自定义侦听器。

Cool,谢谢!这里的信息有点误导我:“Microsoft.ServiceFabric.Services.Remoting.Runtime命名空间包含一个扩展方法,
CreateServiceRemotingListener
,用于无状态和有状态服务,可用于使用默认远程传输协议创建远程侦听器。”
protected override async Task RunAsync(CancellationToken cancellationToken)
{
  await base.RunAsync(cancellationToken);
  await Task.Delay(10000);

  for (int i = 0; i < 10; i++)
  {
    ICustomActor proxy = ActorProxy.Create<ICustomActor>(new ActorId(i));
    await proxy.StartAsync();
  }
}
     protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners() 
 { 
   var remotingListener = new ServiceReplicaListener(context => this.CreateServiceRemotingListener(context)); 
   return new ServiceReplicaListener[] { remotingListener }; 
 }