AK1008 - Warning
Creating actors using Context.System.ActorOf()
inside an actor is discouraged because the resulting actor would not be the child of this actor but the "/user" guardian actor itself. Please use Context.ActorOf()
if your intention is to create a child actor of this actor.
Cause
Creating an IActorRef
Using Context.System.ActorOf()
or Context.System.ActorOf<T>()
inside a class that inherits ReceiveActor
or UntypedActor
would create an actor as a child the "/user" guardian actor instead of a child actor under the invoking actor.
You can suppress this warning message if you specifically intended to create a new actor under the "/user" guardian actor.
Example:
using System;
using Akka.Actor;
public sealed class FirstActor : ReceiveActor
{
public FirstActor()
{
Context.System.ActorOf<MyActor>("newActor");
}
}
public sealed class MyActor : ReceiveActor
{
}
Resolution
Use Context.ActorOf()
or Context.ActorOf<T>()
method instead to create a new child actor:
using System;
using Akka.Actor;
public sealed class FirstActor : ReceiveActor
{
public FirstActor()
{
Context.ActorOf<MyActor>("newActor");
}
}
public sealed class MyActor : ReceiveActor
{
}