Orleans: .NetCore2.0 Runtime Codegen fail in Orleans TP3

Created on 15 Sep 2017  ·  8Comments  ·  Source: dotnet/orleans

When I build a .net core 2.0 application with Orleans , I already add reference Orleans.OrleanCodeGenerator to my Client and Server , but the orleans client and server not load the grains dll , and occur this error :

Unhandled Exception: System.ArgumentException: Cannot find an implementation class for grain interface: Orleans.Interface.IPlayerGrain. Make sure the grain assembly was correctly deployed and loaded in the silo.
   at Orleans.GrainFactory.GetGrainClassData(Type interfaceType, String grainClassNamePrefix)
   at Orleans.GrainFactory.GetGrain[TGrainInterface](Int64 primaryKey, String grainClassNamePrefix)
   at Orleans.Client.Program.Main(String[] args) in C:\Users\Administrator\Documents\visual studio 2017\Projects\OrleansCore\Orleans.Client\Program.cs:line 14

thats my code :

Interface :
``` C#
public interface IPlayerGrain : IGrainWithIntegerKey
{
Task SayHello(string content);
}

Grain : 
``` C#
    public class PlayerGrain : IPlayerGrain
    {
        public Task SayHello(string content)
        {
            Console.WriteLine($"Say {content} to {this.GetPrimaryKeyLong()}");
            return Task.CompletedTask;
        }
    }

Client :
``` C#
var config = ClientConfiguration.LocalhostSilo();
GrainClient.Initialize(config);
var player = GrainClient.GrainFactory.GetGrain(1000);
player.SayHello("Hi!!!");
Console.WriteLine("Press any key to terminate!");
Console.ReadKey();

Server:
``` C#
    var config = ClusterConfiguration.LocalhostPrimarySilo();
    var siloHost = new SiloHost("Orleans",config);
    siloHost.InitializeOrleansSilo();
    siloHost.StartOrleansSilo(true);
    Console.WriteLine("Press any key to terminate!");
    Console.ReadKey();

All 8 comments

@bluexo make sure that the DLLs are loaded before starting your client + silo

@ReubenBond I publish the project to ONE folder and run it , but the error still exsits , has another way to build the project ? Need I load DLLs manually?

client只引用Microsoft.Orleans.Client,版本2.0.0-preview*
server只引用Microsoft.Orleans.Server,版本2.0.0-preview*
其他引用Microsoft.Orleans.Core,版本2.0.0-preview*
然后你再试下
不需要手动加载DLL的
按照例子里的引用就会报错没有加载dll

@Cherrs 你自己测试过TP3了? .net core 2.0 版本 不支持 Build code generator 只支持 Runtime code generator , 你要是不引用 Oreans.OrleansCodeGenerator 不可能正确调用 Grain , 你说的方法我试过了,不行的

@bluexo Orleans.Client和Server本身引用了Microsoft.Orleans.OrleansCodeGenerator,只要引用Client和Server就可以了。需要publish
你贴的代码Grain没有继承Grain这个接口

public class PlayerGrain :Grain,IPlayerGrain
我测试是可用的,测试用例我传到我github了,运行结果在result.png

@bluexo My project works well when use IClusterClient

private async Task InitSiloAsync()
{
    Console.WriteLine("silo initing");

    var config = ClientConfiguration.LocalhostSilo();
    config.FallbackSerializationProvider = typeof(ILBasedSerializer).GetTypeInfo();
    client = new ClientBuilder().UseConfiguration(config).Build();
    await client.Connect();
    Console.WriteLine("connected");
}

You should write PlayerGrain : Grain.

Can report of same issues here.

Was this page helpful?
0 / 5 - 0 ratings