I receive the following error message
The service implementation object was not initialized or is not available. at CoreWCF.Dispatcher.TaskMethodInvoker.InvokeAsync(Object instance, Object[] inputs) at CoreWCF.Dispatcher.DispatchOperationRuntime.<>c__DisplayClass71_0.<<InvokeAsync>b__0>d.MoveNext() --- End of stack trace from previous location --- at CoreWCF.Dispatcher.DispatchOperationRuntime.InvokeAsync(MessageRpc rpc)
Please find below code for your reference.
Startup.cs
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddServiceModelServices().AddServiceModelConfigurationManagerFile("Web.config");
services.AddServiceModelMetadata();
services.AddSingleton<IServiceBehavior, UseRequestHeadersForMetadataAddressBehavior>();
services.AddLogging(loggingBuilder =>
{
loggingBuilder.SetMinimumLevel(LogLevel.Information);
loggingBuilder.AddApplicationInsights("xxxxxxxxxxx930939xxxx");
});
services.AddSingleton<ILoggingContractResolver, LoggingContractResolver>();
IMapper mapper = SappoApiAutoMapperConfiguration.Configure().CreateMapper();
services.AddSingleton<IMessageStoreFactory, AzureBlobMessageStoreFactory>();
services.AddSingleton(mapper);
services.AddSingleton(typeof(IOutboundSappoLogger<>), typeof(OutboundSappoLogger<>));
services.AddSingleton<IBlobStorageSettingsHelper, BlobStorageSettingsHelper>();
services.AddSingleton<IBlobClientFactory, BlobClientFactory>();
services.AddSingleton<IServiceBusFactory>(ctx =>
{
return new ServiceBusFactory();
});
services.AddTransient<IShipperAsnService, ShipperAsnService>();
services.AddHttpContextAccessor();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseServiceModel(serviceBuilder =>
{
serviceBuilder.AddService<ShipperAsnService>(serviceOptions =>
{
serviceOptions.DebugBehavior.IncludeExceptionDetailInFaults = true;
}).AddServiceEndpoint<ShipperAsnService, IShipperAsnService>(new BasicHttpBinding(), "/ShipperAsnService.svc");
serviceBuilder.ConfigureServiceHostBase<ShipperAsnService>(serviceHost =>
{
var behavior = serviceHost.Description.Behaviors.Find<ServiceBehaviorAttribute>();
if (behavior == null)
{
behavior = new ServiceBehaviorAttribute();
serviceHost.Description.Behaviors.Add(behavior);
}
behavior.InstanceContextMode = InstanceContextMode.Single;
behavior.ConcurrencyMode = ConcurrencyMode.Multiple;
behavior.IncludeExceptionDetailInFaults = true;
});
});
}
}
IShipperAsnService.cs
[ServiceContract]
public interface IShipperAsnService
{
[OperationContract]
[WebInvoke]
Task<ServiceResponse> ActionAsync(ShipperAsnRequest shipperBrnAsnRequest);
}
ShipperAsnService.cs
public class ShipperAsnService : BaseShipperService<ShipperAsnRequest, OutboundShipperAsnServiceDto>, IShipperAsnService
{
public ShipperAsnService(
IMessageStoreFactory messageStoreFactory,
IServiceBusFactory serviceBusFactory,
IMapper mapper,
IOutboundSappoLogger<ShipperAsnService> log)
: base(messageStoreFactory, serviceBusFactory, mapper, DestinationApi.SAPPOAsn, log)
{
}
public override async Task<ServiceResponse> ActionAsync(ShipperAsnRequest shipperBrnAsnRequest)
{
return await base.ActionAsync(shipperBrnAsnRequest);
}
}

I am struggling to fix it. I want to resolve this issue.
I just had the same issue and you could try to add
in the ConfigureServices method. The credit goes to Carlos Pons and this blog entry
It even seems unnecessary to register the interface implementation for the service with this line
At least in my own case.
If you don't need a Singleton service you can either use AddTransient or leave the registration out alltogether according to this comment.