-
Create .NET Standard 2.0 class library project for both Grain RPC interface & RPC implementation projects.
-
Add Correct Nuget to those projects:
- GranDen.Orleans.Server.SharedInterface nuget to RPC implementation project.
- Microsoft.Orleans.Core.Abstractions nuget to RPC interface project.
- Microsoft.Orleans.CodeGenerator.MSBuild nuget to both RPC interface & RPC implementation projects.
-
In RPC implementation project, add a class that inherit the
AbstractServiceConfigDelegate<MyGrai>
, theMyGrain
is the C# Orleans Grain class that needs to be dynamic loaded; And this class has two porperties that is for:Action<IApplicationPartManager> AppPartConfigurationAction
:
This configure Orleans Application Part, there has already a basic implementation in parentAbstractServiceConfigDelegate<T>
so it is usally doesn't have to override by yourself.Action<HostBuilderContext, IServiceCollection> ServiceConfigurationAction
:
This property controls the Default Dependecy Injection configuration that Orleans Grain class use, you can left a defualt empty
public override Action<HostBuilderContext, IServiceCollection> ServiceConfigurationAction { get; }
statment if you doesn't have any Dependecy Injection usage in Grain class.
-
Add an attribute
[assembly: KnownAssembly(typeof(IMyGrain))]
on top of the class that previously created, theIMyGrain
is the Orleans Grain RPC interface that is declared in RCP interface project.
Follwing is an example code of the aforementioned 3 & 4 steps:using Orleans.CodeGeneration; [assembly: KnownAssembly(typeof(MyReminder.ShareInterface.IMyReminder))] namespace MyReminder.Grain { // ReSharper disable once UnusedMember.Global public class MyReminderGrainServiceConfigure : AbstractServiceConfigDelegate<MyReminderGrain> { public override Action<HostBuilderContext, IServiceCollection> ServiceConfigurationAction => (ctx, service) => { service.AddTransient<IOutputMsg, OutputMsg>(); }; } }
-
Add
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
inside the RPC implementation project file(*.csproj)'s<PropertyGroup>
.