I have 2 interfaces in my assembly , and 2 grains that implement them.
public interface IGrain1:IGrainWithIntegerKey { void SomeMethod(); }
public interface IGrain2:IGrainWithIntegerKey { void SomeOtherMethod(); }
public Grain1:IGrain1
{
public void SomeMethod()
{
var grain2=this.GrainFactory.GetGrain<IGrain2>([somekey]);
}
}
public Grain2:IGrain2
{
void SomeOtherMethod(){}
}
This call to grain of type IGrain2
throws :
Cannot find an implementation class for grain interface: [path].IGrain2 . Make sure the grain assembly was correctly deployed and loaded in the silo.
I do not get why this exception happens , since both interfaces and grains are in the same assembly. Can anyone provide any idea ?
There are two possible solutions for this case:
<PackageReference Include="Microsoft.Orleans.CodeGenerator.MSBuild" Version="3.4.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
ConfigureApplicationParts
method to register the Assembly. This is not recommended but can be done like this:siloBuilder.ConfigureApplicationParts((Action<IApplicationPartManager>)(parts =>
{
parts.AddApplicationPart(typeof(SomeGrain).Assembly).WithReferences();
}));