[英]Cannot find an implementation class for grain interface
我的程序集中有 2 個接口,以及實現它們的 2 個顆粒。
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(){}
}
這個調用IGrain2
類型的 grain 會拋出:
Cannot find an implementation class for grain interface: [path].IGrain2 . Make sure the grain assembly was correctly deployed and loaded in the silo.
我不明白為什么會發生這種異常,因為接口和顆粒都在同一個程序集中。 任何人都可以提供任何想法嗎?
這種情況有兩種可能的解決方案:
<PackageReference Include="Microsoft.Orleans.CodeGenerator.MSBuild" Version="3.4.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
ConfigureApplicationParts
方法來注冊程序集。 不建議這樣做,但可以這樣做:siloBuilder.ConfigureApplicationParts((Action<IApplicationPartManager>)(parts =>
{
parts.AddApplicationPart(typeof(SomeGrain).Assembly).WithReferences();
}));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.