Okay, here’s the weird thing. I wrestled with this issue for most of yesterday afternoon and saw the exception being thrown every time I used any client service other than JSV and JSON.
At the end of the day, I left my machine running overnight, then this morning I ran it again to create a fresh exception message to send to you. I didn’t make any code changes, or even re-compile. This morning it is working as expected for all client services.
To prove that I wasn’t going mad, I 'm pasting the last exception from yesterday’s log file in case it sheds any light:
[15:40:32.481428][ThrdId: 31][DBG] CreateContentTypeRequest/hasContentBody:True:POST:application/x-protobuf:70:
[15:40:32.492371][ThrdId: 31][ERR] Could not deserialize 'application/x-protobuf' request using ABD.Track.DataService.App.CrossCutting.Core.Data.Entities.VehicleManufacturerEntities.DeleteVehicleManufacturer[]'
Error: System.InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at ProtoBuf.ProtoReader.StreamProtoReader.Ensure(State& state, Int32 count, Boolean strict) in /_/src/protobuf-net.Core/ProtoReader.Stream.cs:line 382
at ProtoBuf.ProtoReader.StreamProtoReader.ImplTryReadUInt32VarintWithoutMoving(State& state, Read32VarintMode mode, UInt32& value) in /_/src/protobuf-net.Core/ProtoReader.Stream.cs:line 189
at ProtoBuf.ProtoReader.State.ReadFieldHeaderFallback() in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 706
at ProtoBuf.ProtoReader.State.<ReadAsRoot>g__ReadFieldOne|101_0[T](State& state, SerializerFeatures features, T value, ISerializer`1 serializer) in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 1066
at ProtoBuf.ProtoReader.State.ReadAsRoot[T](T value, ISerializer`1 serializer) in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 1058
at ProtoBuf.ProtoReader.State.DeserializeRoot[T](T value, ISerializer`1 serializer) in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 1032
at ProtoBuf.Internal.DynamicStub.ConcreteStub`1.TryDeserializeRoot(TypeModel model, State& state, Object& value, Boolean autoCreate) in /_/src/protobuf-net.Core/Internal/DynamicStub.cs:line 184
at ProtoBuf.Meta.TypeModel.DeserializeRootAny(State& state, Type type, Object value, Boolean autoCreate) in /_/src/protobuf-net.Core/Meta/TypeModel.cs:line 1057
at ProtoBuf.ProtoReader.State.DeserializeRootFallback(Object value, Type type) in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 1142
at ProtoBuf.Meta.TypeModel.Deserialize(Stream source, Object value, Type type) in /_/src/protobuf-net.Core/Meta/TypeModel.cs:line 707
at ServiceStack.ProtoBuf.ProtoBufFormat.Deserialize(Type type, Stream fromStream) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack.ProtoBuf\ProtoBufFormat.cs:line 35
at ServiceStack.Host.ContentTypes.<>c__DisplayClass37_0.<GetStreamDeserializerAsync>b__0(Type type, Stream stream) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\ContentTypes.cs:line 366
at ServiceStack.Host.Handlers.ServiceStackHandlerBase.CreateContentTypeRequestAsync(IRequest httpReq, Type requestType, String contentType) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\Handlers\ServiceStackHandlerBase.cs:line 221
System.Runtime.Serialization.SerializationException: Could not deserialize 'application/x-protobuf' request using ABD.Track.DataService.App.CrossCutting.Core.Data.Entities.VehicleManufacturerEntities.DeleteVehicleManufacturer[]'
Error: System.InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at ProtoBuf.ProtoReader.StreamProtoReader.Ensure(State& state, Int32 count, Boolean strict) in /_/src/protobuf-net.Core/ProtoReader.Stream.cs:line 382
at ProtoBuf.ProtoReader.StreamProtoReader.ImplTryReadUInt32VarintWithoutMoving(State& state, Read32VarintMode mode, UInt32& value) in /_/src/protobuf-net.Core/ProtoReader.Stream.cs:line 189
at ProtoBuf.ProtoReader.State.ReadFieldHeaderFallback() in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 706
at ProtoBuf.ProtoReader.State.<ReadAsRoot>g__ReadFieldOne|101_0[T](State& state, SerializerFeatures features, T value, ISerializer`1 serializer) in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 1066
at ProtoBuf.ProtoReader.State.ReadAsRoot[T](T value, ISerializer`1 serializer) in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 1058
at ProtoBuf.ProtoReader.State.DeserializeRoot[T](T value, ISerializer`1 serializer) in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 1032
at ProtoBuf.Internal.DynamicStub.ConcreteStub`1.TryDeserializeRoot(TypeModel model, State& state, Object& value, Boolean autoCreate) in /_/src/protobuf-net.Core/Internal/DynamicStub.cs:line 184
at ProtoBuf.Meta.TypeModel.DeserializeRootAny(State& state, Type type, Object value, Boolean autoCreate) in /_/src/protobuf-net.Core/Meta/TypeModel.cs:line 1057
at ProtoBuf.ProtoReader.State.DeserializeRootFallback(Object value, Type type) in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 1142
at ProtoBuf.Meta.TypeModel.Deserialize(Stream source, Object value, Type type) in /_/src/protobuf-net.Core/Meta/TypeModel.cs:line 707
at ServiceStack.ProtoBuf.ProtoBufFormat.Deserialize(Type type, Stream fromStream) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack.ProtoBuf\ProtoBufFormat.cs:line 35
at ServiceStack.Host.ContentTypes.<>c__DisplayClass37_0.<GetStreamDeserializerAsync>b__0(Type type, Stream stream) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\ContentTypes.cs:line 366
at ServiceStack.Host.Handlers.ServiceStackHandlerBase.CreateContentTypeRequestAsync(IRequest httpReq, Type requestType, String contentType) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\Handlers\ServiceStackHandlerBase.cs:line 221
---> System.InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at ProtoBuf.ProtoReader.StreamProtoReader.Ensure(State& state, Int32 count, Boolean strict) in /_/src/protobuf-net.Core/ProtoReader.Stream.cs:line 382
at ProtoBuf.ProtoReader.StreamProtoReader.ImplTryReadUInt32VarintWithoutMoving(State& state, Read32VarintMode mode, UInt32& value) in /_/src/protobuf-net.Core/ProtoReader.Stream.cs:line 189
at ProtoBuf.ProtoReader.State.ReadFieldHeaderFallback() in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 706
at ProtoBuf.ProtoReader.State.<ReadAsRoot>g__ReadFieldOne|101_0[T](State& state, SerializerFeatures features, T value, ISerializer`1 serializer) in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 1066
at ProtoBuf.ProtoReader.State.ReadAsRoot[T](T value, ISerializer`1 serializer) in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 1058
at ProtoBuf.ProtoReader.State.DeserializeRoot[T](T value, ISerializer`1 serializer) in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 1032
at ProtoBuf.Internal.DynamicStub.ConcreteStub`1.TryDeserializeRoot(TypeModel model, State& state, Object& value, Boolean autoCreate) in /_/src/protobuf-net.Core/Internal/DynamicStub.cs:line 184
at ProtoBuf.Meta.TypeModel.DeserializeRootAny(State& state, Type type, Object value, Boolean autoCreate) in /_/src/protobuf-net.Core/Meta/TypeModel.cs:line 1057
at ProtoBuf.ProtoReader.State.DeserializeRootFallback(Object value, Type type) in /_/src/protobuf-net.Core/ProtoReader.State.ReadMethods.cs:line 1142
at ProtoBuf.Meta.TypeModel.Deserialize(Stream source, Object value, Type type) in /_/src/protobuf-net.Core/Meta/TypeModel.cs:line 707
at ServiceStack.ProtoBuf.ProtoBufFormat.Deserialize(Type type, Stream fromStream) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack.ProtoBuf\ProtoBufFormat.cs:line 35
at ServiceStack.Host.ContentTypes.<>c__DisplayClass37_0.<GetStreamDeserializerAsync>b__0(Type type, Stream stream) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\ContentTypes.cs:line 366
at ServiceStack.Host.Handlers.ServiceStackHandlerBase.CreateContentTypeRequestAsync(IRequest httpReq, Type requestType, String contentType) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\Handlers\ServiceStackHandlerBase.cs:line 221
--- End of inner exception stack trace ---
at ServiceStack.Host.Handlers.ServiceStackHandlerBase.CreateContentTypeRequestAsync(IRequest httpReq, Type requestType, String contentType) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\Handlers\ServiceStackHandlerBase.cs:line 229
at ServiceStack.Host.Handlers.ServiceStackHandlerBase.DeserializeHttpRequestAsync(Type operationType, IRequest httpReq, String contentType) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\Handlers\ServiceStackHandlerBase.cs:line 183
at ServiceStack.Host.Handlers.GenericHandler.CreateRequestAsync(IRequest req, String operationName) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\Handlers\GenericHandler.cs:line 32
at ServiceStack.Host.Handlers.GenericHandler.ProcessRequestAsync(IRequest httpReq, IResponse httpRes, String operationName) in C:\BuildAgent\work\3481147c480f4a2f\src\ServiceStack\Host\Handlers\GenericHandler.cs:line 53
This is the deletion DTO:
[ProtoContract]
[Route( "/api/vehicleManufacturers/{Id}", HttpMethods.Delete, Summary = "Delete a Vehicle Manufacturer" )]
public class DeleteVehicleManufacturer : IDeleteDb< VehicleManufacturer >, IReturn< DeleteVehicleManufacturerResponse >, IChangeDb, IHasIntId
{
#region Properties and Indexers
[ProtoMember( 1, DataFormat = DataFormat.ZigZag )]
public int Id { get; set; }
[ProtoMember( 2 )]
public ulong RowVersion { get; set; }
[ProtoMember( 3 )]
public string NamedConnection { get; set; }
#endregion
}
The response (so that I can log the Id(s) affected by the deletion):
[ProtoContract]
public class DeleteVehicleManufacturerResponse : IHasResponseStatus, IHasIntId
{
#region Properties and Indexers
[ProtoMember( 1, DataFormat = DataFormat.ZigZag )]
public int Id { get; set; }
[ProtoMember( 2 )]
public ResponseStatus ResponseStatus { get; set; }
#endregion
}
And the triggering call:
var requests = new List< DeleteVehicleManufacturer >( batched.Length );
foreach ( var vehicleManufacturer in batched )
{
requests.Add(
new DeleteVehicleManufacturer
{
Id = vehicleManufacturer.Id,
RowVersion = vehicleManufacturer.RowVersion,
NamedConnection = Constants.DatabaseName
} );
}
var responses = await _client.SendAllAsync( requests ).ConfigureAwait( false );