I'm working on a simple Service Fabric cluster, where I want to call a stateless service from a stateless ASP.NET Core 2.0 web API.
The first thing I did was create a .NET Standard 2.0 class library with a simple interface and DTO:
public interface IMicroService : IService
{
Task<MyDto> GetMahDto(int id);
}
public class MyDto
{
public string Name { get; set; }
}
Then I created a NuGet package out of it, and added the package as a dependency to both my web API (MyServiceApi project) and the stateless service (MyService).
The listener for the service is defined as
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
var fabricListener = new ServiceInstanceListener((context) =>
{
var fabricRemotingListener = new FabricTransportServiceRemotingListener(
serviceContext: context,
serviceRemotingMessageHandler: null,
remotingListenerSettings: new Microsoft.ServiceFabric.Services.Remoting.FabricTransport.Runtime.FabricTransportRemotingListenerSettings()
{
EndpointResourceName = "myendpoint"
},
serializationProvider: null);
return fabricRemotingListener;
},
"mylistener");
return new ServiceInstanceListener[] { fabricListener };
}
and the interface implementation is simply
public Task<MyDto> GetMahDto(int id)
{
return Task.FromResult(new MyDto() { Name=$"Hallo from TheService in FabricSandbox3 project, id: {id}" });
}
In MyServiceApi, I have a controller method that looks like
[HttpGet]
public async Task<MyDto> Get()
{
var svc = ServiceProxy.Create<ContractsStandard.IMicroService>(new Uri("fabric:/FabricSandbox4/TheService"), listenerName: "mylistener");
return await svc.GetMahDto(23);
}
When I start the debugger, I am able to step into the controller method of MyServiceApi, but it throws the following exception:
System.AggregateException: 'One or more errors occurred. (The exception System.ArgumentException was unhandled on the service and could not be serialized for transferring to the client.
Detailed Remote Exception Information: System.ArgumentException: No interface found with this Id -488762776
at Microsoft.ServiceFabric.Services.Remoting.V2.ServiceRemotingMessageSerializersManager.GetInterfaceDetails(Int32 interfaceId)
at Microsoft.ServiceFabric.Services.Remoting.V2.ServiceRemotingMessageSerializersManager.CreateSerializers(Int32 interfaceId)
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func
2 valueFactory)
at Microsoft.ServiceFabric.Services.Remoting.V2.ServiceRemotingMessageSerializersManager.GetRequestBodySerializer(Int32 interfaceId)
at Microsoft.ServiceFabric.Services.Remoting.V2.FabricTransport.Runtime.FabricTransportMessageHandler.CreateRemotingRequestMessage(FabricTransportMessage fabricTransportMessage, Stopwatch stopwatch)
at Microsoft.ServiceFabric.Services.Remoting.V2.FabricTransport.Runtime.FabricTransportMessageHandler.d__7.MoveNext())'
I haven't found anything in my diagnostic events that looks promising, and the only mentions I've seen of similar issues (on this site and elsewhere) typically involved types in different assemblies, which isn't an issue given that the shared interface is contained in a NuGet package.
Any ideas where I might be going wrong here?