Zaid-Ajaj / Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
https://zaid-ajaj.github.io/Fable.Remoting/
MIT License
272 stars 55 forks source link

Issue with ProjectReference and shared module code #343

Closed Darkle closed 1 year ago

Darkle commented 1 year ago

Hi, I have a repo which contains multiple F# projects. I would like to share some code between these projects, so I have put the shared code in a "shared" project folder and reference them in each F# projects .fsproj file using ProjectReference - e.g. This is in the api.fsproj file.

  <ItemGroup>
    <ProjectReference Include="..\..\shared\shared.fsproj" />
  </ItemGroup>  

In the shared code I have a Logger module which sends logs to the api via fable remoting. However whenever the fable remoting client code is called, I get an error of:

System.NullReferenceException: Object reference not set to an instance of an object.

I have created a minimal reproduction here: https://github.com/Darkle/fable-remoting-issue-temp If you run dotnet restore in both folders, then in the api folder run dotnet run, you will get an error message of:

(Object reference not set to an instance of an object.)
       ---> System.NullReferenceException: Object reference not set to an instance of an object.
Darkle commented 1 year ago

Looks like it wasn't an issue with fable remoting but with my fsproj file. I switched the shared.fsproj file to have <OutputType>Library</OutputType> instead of <OutputType>Exe</OutputType> and it seems to work fine now.