dotnet / orleans

Cloud Native application framework for .NET
https://docs.microsoft.com/dotnet/orleans
MIT License
10.07k stars 2.03k forks source link

Orleans.Runtime.OrleansConfigurationException #4633

Closed bouyeijiang closed 6 years ago

bouyeijiang commented 6 years ago

i can't initialize configuration for orleans framework and that exception error about is it: None of the assemblies added to ApplicationPartManager contain generated code. Ensure that code generation has been executed for grain interface and class assemblies.

my code: interface code:

public interface IQueryLayer:IGrainWithIntegerKey { Task<List> QueryPhone(string cond); }

instance:

public class QueryLayer:Grain,IQueryLayer { static List collection = new List(); public override Task OnActivateAsync() { collection.AddRange(new string[] {"12345","23456","1254204","2142212","12451212","1824557" }); return base.OnActivateAsync(); }

    public Task<List<string>> QueryPhone(string cond)
    {
        var items = collection.FindAll(x => x.Contains(cond));
        return Task.FromResult<List<string>>(items);
    }
}

function main: var hostBuilder = new SiloHostBuilder().UseLocalhostClustering().Configure(options => { options.ClusterId = "dev"; options.ServiceId = "bouyei"; }) .Configure(options => options.AdvertisedIPAddress = IPAddress.Loopback) .ConfigureApplicationParts(p => p.AddApplicationPart(typeof(QueryLayer).Assembly).WithReferences()) .ConfigureLogging(logging => logging.AddFilter(x => x == LogLevel.Debug));

        using (var host = hostBuilder.Build())
        {
            host.StartAsync().ContinueWith(x =>
            {
                Console.WriteLine("stared!");
            });

            Console.ReadKey();
            host.StopAsync().ContinueWith(x=> {
                Console.WriteLine("stoped!");
            });
        }
ReubenBond commented 6 years ago

Add this package to your QueryLayer project: https://www.nuget.org/packages/Microsoft.Orleans.OrleansCodeGenerator.Build/

bouyeijiang commented 6 years ago

it is base on .net core project,but no effect

bouyeijiang commented 6 years ago

i got,it can be used.but client exception System.InvalidOperationException:“Cannot find generated GrainReference class for interface 'ICorBusLayer.IQueryLayer'”

bouyeijiang commented 6 years ago

i got , still reference https://www.nuget.org/packages/Microsoft.Orleans.OrleansCodeGenerator.Build/

sergeybykov commented 6 years ago

@bouyeijiang Did you get it to work? The combination of Microsoft.Orleans.OrleansCodeGenerator.Build and AddApplicationPart should do the job.

bouyeijiang commented 6 years ago

yeah,it is to work

sergeybykov commented 6 years ago

Thanks. I'll close this then.