Search code examples
c#orleans

Orleans Grain Collection Template in VS, has it changed?


I am using the v1.0.5 release of the Microsoft Orleans SDK and am following along in the Running in a Stand alone Silo Microsoft Orleans Tutorial

And it suggests the following:

If you set the grain collection project as a startup project and hit F5, you will notice that it's started and hosted by a silo called "OrleansHost."...

But as far as I can the Grain Collection Project is a class library, has this changed since the tutorial was written (I notice that it uses the old OrleansClient and not GrainClient).

That main method just below:

static void Main(string[] args){
    Console.WriteLine("Waiting`enter code here` for Orleans Silo to start. Press Enter to proceed...");
    Console.ReadLine();
    Orleans.OrleansClient.Initialize("DevTestClientConfiguration.xml");
}

I believe is for the SiloHost.


Solution

  • You have to set to Startup both

    • the project containing the Program.cs (the client) and
    • the Grain project.

    See the Grain project's Properties/Debug/Start external program (it should be something like: C:\Orleans\SDK\LocalSilo\OrleansHost.exe), it will start the grain .dll-s with the local OrleansHost silo in the SDK.

    You can exit at the end the local OrleansHost silo with CTRL-C.

    EDIT

    There are 3 lines in the .csproj of the Grain project that is important:

        <StartAction>Program</StartAction>
        <StartProgram>$(OrleansSDK)\LocalSilo\OrleansHost.exe</StartProgram>
        <StartWorkingDirectory>$(OrleansSDK)\LocalSilo</StartWorkingDirectory>
    

    This is inserted by the project template or by the NuGet package, so you do not need to edit these. Only in case of some problem, eg. you relocate the Orleans SDK.

    When you relocate the SDK, modify the OrleansSDK environment variable (Control panel/Advanced/Environment variables/System variables) and not the Grain project's properties!