`IGrainReferenceActivatorProvider` exception with interfaces written in F#
- Dominant language
- C#
- Stars
- 10.9k
- Forks
- 2.1k
- Avg merge
- 14h 42m
- Merged PRs (30d)
- 354
Description
I've checked out the [F# sample app](https://github.com/dotnet/samples/tree/main/orleans/FSharpHelloWorld) and found out that interfaces in that sample app are written in C#.
Since there's not much point in using F# while being restricted to C# types (one can't use F# types in C# interfaces), I rewrote that assembly in F#.
IHelloGrain.fs
```fsharp
namespace HelloWorldInterfaces
open System.Threading.Tasks
open Orleans
type IHelloGrain =
inherit IGrainWithIntegerKey
abstract member SayHello : message:string -> ValueTask
```
HelloWorldInterfaces.fsproj
```csproj
net8.0
```
Problem is that after applying the above change (and fixing reference paths from `.csproj` to `.fsproj`), now I'm getting:
```
Unhandled exception. System.InvalidOperationException: Unable to find an IGrainReferenceActivatorProvider for grain type hello
at Orleans.GrainReferences.GrainReferenceActivator.CreateActivator(GrainType grainType, GrainInterfaceType interfaceType) in /_/src/Orleans.Core/GrainReferences/GrainReferenceActivator.cs:line 85
at Orleans.GrainReferences.GrainReferenceActivator.CreateReference(GrainId grainId, GrainInterfaceType interfaceType) in /_/src/Orleans.Core/GrainReferences/GrainReferenceActivator.cs:line 54
at Orleans.GrainFactory.GetGrain(Type interfaceType, IdSpan grainKey, String grainClassNamePrefix) in /_/src/Orleans.Core/Core/GrainFactory.cs:line 217
at Orleans.GrainFactory.GetGrain[TGrainInterface](Int64 primaryKey, String grainClassNamePrefix) in /_/src/Orleans.Core/Core/GrainFactory.cs:line 51
at Program.$(String[] args) in /home/peter/work/org/dotnet-samples/orleans/FSharpHelloWorld/HelloWorld/Program.cs:line 21
at Program.(String[] args)
```
How can I fix the above problem?
How can I declare interfaces with F# types in Orleans project?
Contributor guide
Research direction
Start with the FSharpHelloWorld sample, especially IHelloGrain.fs, HelloWorldInterfaces.fsproj, and HelloWorld/Program.cs, then reproduce the failure at GrainFactory.GetGrain. Compare the F# interface setup with the sample's original C# interface and trace the reported GrainReferenceActivator exception. Done means the F# interface can be used without the IGrainReferenceActivatorProvider error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, fsharp
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100