Orleans Visual Basic sample app
This sample demonstrates how to use Visual Basic to write grain code. The sample consists of three projects:
- HelloWorldInterfaces: a C# project containing a grain interface,
IHelloGrain
. - Grains: an Visual Basic projects implementing
IHelloGrain
. - HelloWorld: A C# project to host the grains.
The Microsoft.Orleans.Sdk
package does not support emitting Visual Basic code, however, it supports analyzing Visual Basic assemblies and emitting C# code. Therefore, this sample works by instructing the code generator to analyze the Grains
project when it is generating code for the HelloWorld
project. This is accomplished using the following directive in HelloWorld
's Program.cs
file:
[assembly: GenerateCodeForDeclaringAssembly(typeof(HelloGrain))]
[assembly: GenerateCodeForDeclaringAssembly(typeof(IHelloGrain))]
With the above attribute in place, the code generator analyzes the Visual Basic assembly and emits C# code into the HelloWorld
project.
Sample prerequisites
This sample is written in C# and targets .NET 7.0. It requires the .NET 7.0 SDK or later.
Building the sample
To download and run the sample, follow these steps:
- Download and unzip the sample.
- In Visual Studio (2022 or later):
- On the menu bar, choose File > Open > Project/Solution.
- Navigate to the folder that holds the unzipped sample code, and open the C# project (.csproj) file.
- Choose the F5 key to run with debugging, or Ctrl+F5 keys to run the project without debugging.
- From the command line:
- Navigate to the folder that holds the unzipped sample code.
- At the command line, type
dotnet run
.
Running the sample
Run the sample by opening a terminal window and executing the following at the command prompt:
dotnet run --project HelloWorld