Stackoverflow error comes in Microsoft.Extensions.Hosting class - c#

I had Azure function which was written using .NET Core 3.1 and suddenly stopped working and showing StackOverflow exception in below code at TryAddEnumerables
Here is my stack trace
My startup class
builder.Services
.AddSingleton<IConfiguration>(config)
.AddSingleton(serviceProvider => serviceProvider)
.AddLogging()
.AddSingleton<IManager, CManager>()
.AddSingleton<IRegexManager, RegexManager>()
Removing below line solves the StackOverflow error but not sure on side affects of it
AddSingleton(serviceProvider => serviceProvider)
Trace
System.Private.CoreLib.dll!Interop.Advapi32.EventWriteTransfer_PInvoke(long registrationHandle, System.Diagnostics.Tracing.EventDescriptor eventDescriptor, System.Guid* activityId, System.Guid* relatedActivityId, int userDataCount, System.Diagnostics.Tracing.EventProvider.EventData* userData) Unknown
System.StackOverflowException
HResult=0x800703E9
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace
System.Private.CoreLib.dll!Interop.Advapi32.EventWriteTransfer(long registrationHandle, System.Diagnostics.Tracing.EventDescriptor eventDescriptor, System.Guid* activityId, System.Guid* relatedActivityId, int userDataCount, System.Diagnostics.Tracing.EventProvider.EventData* userData) Unknown
System.Private.CoreLib.dll!System.Diagnostics.Tracing.EtwEventProvider.System.Diagnostics.Tracing.IEventProvider.EventWriteTransfer(long registrationHandle, System.Diagnostics.Tracing.EventDescriptor eventDescriptor, System.IntPtr eventHandle, System.Guid* activityId, System.Guid* relatedActivityId, int userDataCount, System.Diagnostics.Tracing.EventProvider.EventData* userData) Unknown
System.Private.CoreLib.dll!System.Diagnostics.Tracing.EventProvider.WriteEvent(ref System.Diagnostics.Tracing.EventDescriptor eventDescriptor, System.IntPtr eventHandle, System.Guid* activityID, System.Guid* childActivityID, int dataCount, System.IntPtr data) Unknown
System.Private.CoreLib.dll!System.Diagnostics.Tracing.EventSource.WriteEventWithRelatedActivityIdCore(int eventId, System.Guid* relatedActivityId, int eventDataCount, System.Diagnostics.Tracing.EventSource.EventData* data) Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.TplEventSource.TraceOperationBegin(int TaskID, string OperationName, long RelatedContext) Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.AsyncCausalityTracer.TraceOperationCreation(System.Threading.Tasks.Task task, string operationName) Unknown
System.Private.CoreLib.dll!System.Threading.Tasks.Task.ScheduleAndStart(bool needsProtection) Unknown

Related

C# SOAP Middleware MessageEncoder.WriteMessage

I try to run this tutorial: custom-asp-net-core-middleware-example
But the reponse message at the client say´s:
S
ystem.ServiceModel.ProtocolException: There is a problem with the XML that was received from the network. See inner exception for more details.
---> System.Xml.XmlException: Name cannot begin with the '/' character, hexadecimal value 0x2F. Line 1, position 74.
at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, XmlException exception)
at System.Xml.XmlUTF8TextReader.VerifyNCName(String s)
at System.Xml.XmlUTF8TextReader.ReadQualifiedName(PrefixHandle prefix, StringHandle localName)
at System.Xml.XmlUTF8TextReader.ReadStartElement()
at System.Xml.XmlUTF8TextReader.Read()
at System.ServiceModel.Channels.Message.ReadStartBody(XmlDictionaryReader reader, EnvelopeVersion envelopeVersion, Boolean& isFault, Boolean& isEmpty)
at System.ServiceModel.Channels.ReceivedMessage.ReadStartBody(XmlDictionaryReader reader)
at System.ServiceModel.Channels.BufferedMessage..ctor(IBufferedMessageData messageData, RecycledMessageState recycledMessageState, Boolean[] understoodHeaders, Boolean understoodHeadersModified)
at System.ServiceModel.Channels.BufferedMessage..ctor(IBufferedMessageData messageData, RecycledMessageState recycledMessageState)
at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.ReadMessage(ArraySegment`1 buffer, BufferManager bufferManager, String contentType)
at System.ServiceModel.Channels.MessageEncoder.ReadMessageAsync(Stream stream, BufferManager bufferManager, Int32 maxBufferSize, String contentType, CancellationToken cancellationToken)
at System.ServiceModel.Channels.HttpResponseMessageHelper.ReadChunkedBufferedMessageAsync(Task`1 inputStreamTask, TimeoutHelper timeoutHelper)
--- End of inner exception stack trace ---
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.<CreateGenericTask>b__0(IAsyncResult asyncResult)
I´ve also encounterd a problem with the request-message so I´ve written my own RequestMessage but I´m not sure whether I should write my own ResponseMessage, because I do not know how it should be.
Also I´ve changed the OperationDescription to fit the tutorials code, may there be the problem?
public OperationDescription(ContractDescription contract, MethodInfo operationMethod, OperationContractAttribute contractAttribute)
{
Contract = contract;
SoapAction = contractAttribute.Name ?? operationMethod.Name;
Name = contractAttribute.Action ?? $"{contract.Namespace.TrimEnd('/')}/{contract.Name}/{Name}".Trim('/');
IsOneWay = contractAttribute.IsOneWay;
ReplyAction = contractAttribute.ReplyAction;
DispatchMethod = operationMethod;
}

Xamarin Hot Reload not failed to initialize

After the last updates of Visual Studio version 16.9.x and update to Xamarin.Forms 5.0 Hot Reload not working.
This is the Output i get when starting the application:
Hot Reload IDE Extension Loaded
(FinansovoPregledi.Android) XAML Hot Reload is using 'changes only' mode
XAML Hot Reload initializing...
WARN: (FinansovoPregledi.Android) Unknown Breakpoint Hit: Android.Runtime.JNIEnv.RegisterJniNatives( typeName_ptr, int typeName_len, jniClass, methods_ptr, int methods_len)
ERROR: Caught exception in AgentStatusChangedHandler at 268: Xamarin.HotReload.EvaluatorException: Failed to Inject Assembly ---> Mono.Debugging.Evaluation.EvaluatorException: Method `Load' not found in type `System.Reflection.Assembly'.
at Mono.Debugging.Soft.SoftDebuggerAdaptor.OverloadResolveMulti(SoftEvaluationContext ctx, TypeMirror type, String methodName, ArgumentType[] genericTypeArgs, TypeMirror returnType, ArgumentType[] argTypes, List`1 candidates, Boolean throwIfNotFound, Boolean tryCasting) in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerAdaptor.cs:line 2619
at Mono.Debugging.Soft.SoftDebuggerAdaptor.OverloadResolveMulti(SoftEvaluationContext ctx, TypeMirror type, String methodName, ArgumentType[] genericTypeArgs, TypeMirror returnType, ArgumentType[] argTypes, Boolean allowInstance, Boolean allowStatic, Boolean throwIfNotFound, Boolean tryCasting) in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerAdaptor.cs:line 2511
at Mono.Debugging.Soft.SoftDebuggerAdaptor.RuntimeInvoke(EvaluationContext ctx, Object targetType, Object target, String methodName, Object[] genericTypeArgs, Object[] argTypes, Object[] argValues, Boolean enableOutArgs, Object[]& outArgs) in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerAdaptor.cs:line 2304
at Mono.Debugging.Soft.SoftDebuggerAdaptor.RuntimeInvoke(EvaluationContext ctx, Object targetType, Object target, String methodName, Object[] genericTypeArgs, Object[] argTypes, Object[] argValues) in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerAdaptor.cs:line 2281
at Xamarin.HotReload.HotReloadSharedBridge.InjectAndLoadAssembly(IProject project, SoftEvaluationContext context, String assemblyPath) in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadSharedBridge.cs:line 359
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
--- End of inner exception stack trace ---
at Xamarin.HotReload.HotReloadSharedBridge.InjectAndLoadAssembly(IProject project, SoftEvaluationContext context, String assemblyPath) in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadSharedBridge.cs:line 374
at Xamarin.HotReload.HotReloadBridge.<InitializeAgent>d__47.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 140
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.HotReload.HotReloadBridge.<<Debugger_TargetHitBreakpoint>b__50_0>d.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 242
at Xamarin.HotReload.HotReloadSharedBridge.InjectAndLoadAssembly(IProject project, SoftEvaluationContext context, String assemblyPath) in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadSharedBridge.cs:line 374
at Xamarin.HotReload.HotReloadBridge.<InitializeAgent>d__47.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 140
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.HotReload.HotReloadBridge.<<Debugger_TargetHitBreakpoint>b__50_0>d.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 242
XAML Hot Reload encountered a problem and failed to start. Use Help -> Report a Problem if the issues persists.
Stopping All Hot Reload sessions due to Failed ...
(FinansovoPregledi.Android) Stopping a Hot Reload session due to Failed ...
Stopped Hot Reload session.
ERROR: (FinansovoPregledi.Android) Caught exception in Debugger_TargetHitBreakpoint at 246: Xamarin.HotReload.EvaluatorException: Failed to Inject Assembly ---> Mono.Debugging.Evaluation.EvaluatorException: Method `Load' not found in type `System.Reflection.Assembly'.
at Mono.Debugging.Soft.SoftDebuggerAdaptor.OverloadResolveMulti(SoftEvaluationContext ctx, TypeMirror type, String methodName, ArgumentType[] genericTypeArgs, TypeMirror returnType, ArgumentType[] argTypes, List`1 candidates, Boolean throwIfNotFound, Boolean tryCasting) in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerAdaptor.cs:line 2619
at Mono.Debugging.Soft.SoftDebuggerAdaptor.OverloadResolveMulti(SoftEvaluationContext ctx, TypeMirror type, String methodName, ArgumentType[] genericTypeArgs, TypeMirror returnType, ArgumentType[] argTypes, Boolean allowInstance, Boolean allowStatic, Boolean throwIfNotFound, Boolean tryCasting) in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerAdaptor.cs:line 2511
at Mono.Debugging.Soft.SoftDebuggerAdaptor.RuntimeInvoke(EvaluationContext ctx, Object targetType, Object target, String methodName, Object[] genericTypeArgs, Object[] argTypes, Object[] argValues, Boolean enableOutArgs, Object[]& outArgs) in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerAdaptor.cs:line 2304
at Mono.Debugging.Soft.SoftDebuggerAdaptor.RuntimeInvoke(EvaluationContext ctx, Object targetType, Object target, String methodName, Object[] genericTypeArgs, Object[] argTypes, Object[] argValues) in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerAdaptor.cs:line 2281
at Xamarin.HotReload.HotReloadSharedBridge.InjectAndLoadAssembly(IProject project, SoftEvaluationContext context, String assemblyPath) in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadSharedBridge.cs:line 359
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
--- End of inner exception stack trace ---
at Xamarin.HotReload.HotReloadSharedBridge.InjectAndLoadAssembly(IProject project, SoftEvaluationContext context, String assemblyPath) in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadSharedBridge.cs:line 374
at Xamarin.HotReload.HotReloadBridge.<InitializeAgent>d__47.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 140
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.HotReload.HotReloadBridge.<<Debugger_TargetHitBreakpoint>b__50_0>d.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 242
at Xamarin.HotReload.HotReloadSharedBridge.InjectAndLoadAssembly(IProject project, SoftEvaluationContext context, String assemblyPath) in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadSharedBridge.cs:line 374
at Xamarin.HotReload.HotReloadBridge.<InitializeAgent>d__47.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 140
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.HotReload.HotReloadBridge.<<Debugger_TargetHitBreakpoint>b__50_0>d.MoveNext() in D:\a\1\s\HotReload\Source\Xamarin.HotReload.Bridge\HotReloadBridge.cs:line 242
Does anyone have a same problem? I tried everything for all platforms, also selecting to refresh the whole page but nothing fixed my problem. It's so hard without Hot Reload.
In your Android and iOS build settings, check that the Linker is set to "Don't Link" or "Link None".
More detailed info about XAML Hot Reload for Xamarin.Forms, you can take a look:
https://learn.microsoft.com/en-us/xamarin/xamarin-forms/xaml/hot-reload

How to fix SQL Exception happening only in android?

I'm using xamarin forms to develop a cross-platform app.
As part of my app, I have a login page where the user enters his credentials and gets authenticated.
I'm using entity framework core and I'm connecting to a SQL server which is hosted on Azures cloud.
The code works and I can log in successfully, but only with IOS and UWP, if i try with Android I receive this exception:
System.Data.SqlClient.SqlException: <Timeout exceeded getting exception details>
If I continue the debugging I receive another exception which is:
System.Data.SqlClient.SqlException: Snix_PreLogin (provider: SNI_PN6, error: 31 - SNI_ERROR_31) Snix_PreLogin (provider: SNI_PN6, error: 31 - SNI_ERROR_31)
This is my Icommand:
LoginCommand = new Command(async () => await Login());
this is my method inside the view-model:
private async Task Login()
{
IsBusy = true;
if (String.IsNullOrWhiteSpace(_emailField) || String.IsNullOrWhiteSpace(_passwordField))
await App.Current.MainPage.DisplayAlert("Error", "All fields must contain values.", "Ok");
else
{
if (await DatabaseHandler.LoginUser(_emailField, _passwordField))
{
App.CurrentAccount = new UserAccount { Email = _emailField, Password = _passwordField };
App.Current.MainPage = new MainPage();
}
else
await App.Current.MainPage.DisplayAlert("Error", "Email or password are incorrect.", "Ok");
}
IsBusy = false;
}
and this is my method inside the DatabaseHandler:
public static async Task<bool> LoginUser(string email, string password)
{
AzureContext AzureDb = new AzureContext();
App.CurrentAccount = await AzureDb.UserAccounts.SingleOrDefaultAsync(account => account.Email == email && account.Password == password);
return (App.CurrentAccount == null) ? false : true;
}
Another thing worth mentioning is that when I comment out the IsBusy lines in the Login method which are responsible for the activity indicator, I no longer get an exception.
But, it's still not working, instead of an exception the UI just freezes for a long time and after it unfreezes nothing happens.
Help would be appreciated.
EDIT:
After playing around a little with the exception handling the full exception i get is this:
{System.Data.SqlClient.SqlException (0x80131904): Snix_PreLogin (provider: SNI_PN6, error: 31 - SNI_ERROR_31)Snix_PreLogin (provider: SNI_PN6, error: 31 - SNI_ERROR_31) ---> System.AggregateException: One or more errors occurred. (Authentication failed, see inner exception.)
---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.AggregateException: One or more errors occurred. (Unable to write data to the transport connection: Connection reset by peer.)
---> System.IO.IOException: Unable to write data to the transport connection: Connection reset by peer. ---> System.Net.Sockets.SocketException: Connection reset by peer at System.Net.Sockets.Socket.Send (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00016] in <634e1667c20e48cfb6aa884228f8db67>:0 at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x0009b] in <634e1667c20e48cfb6aa884228f8db67>:0 --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x000e2] in <634e1667c20e48cfb6aa884228f8db67>:0 at System.Data.SqlClient.SNI.SslOverTdsStream.WriteInternal (System.Byte[] buffer, System.Int32 offset, System.Int32 count, System.Threading.CancellationToken token, System.Boolean async) [0x0017b] in <fb2d0bc6c8f7446eaa3eaa0ac572f8d3>:0 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <84c6975c2cbc47b489a2a76477d7a312>:0 at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <84c6975c2cbc47b489a2a76477d7a312>:0 at System.Threading.Tasks.Task.Wait () [0x00000] in <84c6975c2cbc47b489a2a76477d7a312>:0 at System.Data.SqlClient.SNI.SslOverTdsStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x0000f] in <fb2d0bc6c8f7446eaa3eaa0ac572f8d3>:0 at Mono.Net.Security.MobileAuthenticatedStream.<InnerWrite>b__86_0 () [0x00006] in <634e1667c20e48cfb6aa884228f8db67>:0 at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in <84c6975c2cbc47b489a2a76477d7a312>:0 at System.Threading.Tasks.Task.Execute () [0x00000] in <84c6975c2cbc47b489a2a76477d7a312>:0 --- End of stack trace from previous location where exception was thrown --- at Mono.Net.Security.MobileAuthenticatedStream.InnerWrite (System.Boolean sync, System.Threading.CancellationToken cancellationToken) [0x000d3] in <634e1667c20e48cfb6aa884228f8db67>:0 at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x00196] in <634e1667c20e48cfb6aa884228f8db67>:0 at Mono.Net.Security.AsyncProtocolRequest.StartOperation (System.Threading.CancellationToken cancellationToken) [0x0008b] in <634e1667c20e48cfb6aa884228f8db67>:0 --- End of inner exception stack trace --- at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x00252] in <634e1667c20e48cfb6aa884228f8db67>:0 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <84c6975c2cbc47b489a2a76477d7a312>:0 at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <84c6975c2cbc47b489a2a76477d7a312>:0 at System.Threading.Tasks.Task.Wait () [0x00000] in <84c6975c2cbc47b489a2a76477d7a312>:0 at Mono.Net.Security.MobileAuthenticatedStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) [0x0003d] in <634e1667c20e48cfb6aa884228f8db67>:0 at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.AuthenticateAsClient(string,System.Security.Cryptography.X509Certificates.X509CertificateCollection,System.Security.Authentication.SslProtocols,bool) at Mono.Net.Security.MobileAuthenticatedStream.AuthenticateAsClient (System.String targetHost) [0x00007] in <634e1667c20e48cfb6aa884228f8db67>:0 at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost) [0x00006] in <634e1667c20e48cfb6aa884228f8db67>:0 at System.Data.SqlClient.SNI.SNITCPHandle.EnableSsl (System.UInt32 options) [0x0000c] in <fb2d0bc6c8f7446eaa3eaa0ac572f8d3>:0 at System.Data.SqlClient.SNI.SNIProxy.EnableSsl (System.Data.SqlClient.SNI.SNIHandle handle, System.UInt32 options) [0x00000] in <fb2d0bc6c8f7446eaa3eaa0ac572f8d3>:0 ---> (Inner Exception #0) System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.AggregateException: One or more errors occurred. (Unable to write data to the transport connection: Connection reset by peer.)
---> System.IO.IOException: Unable to write data to the transport connection: Connection reset by peer. ---> System.Net.Sockets.SocketException: Connection reset by peer at System.Net.Sockets.Socket.Send (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00016] in <634e1667c20e48cfb6aa884228f8db67>:0 at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x0009b] in <634e1667c20e48cfb6aa884228f8db67>:0 --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 size) [0x000e2] in <634e1667c20e48cfb6aa884228f8db67>:0 at System.Data.SqlClient.SNI.SslOverTdsStream.WriteInternal (System.Byte[] buffer, System.Int32 offset, System.Int32 count, System.Threading.CancellationToken token, System.Boolean async) [0x0017b] in <fb2d0bc6c8f7446eaa3eaa0ac572f8d3>:0 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <84c6975c2cbc47b489a2a76477d7a312>:0 at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <84c6975c2cbc47b489a2a76477d7a312>:0 at System.Threading.Tasks.Task.Wait () [0x00000] in <84c6975c2cbc47b489a2a76477d7a312>:0 at System.Data.SqlClient.SNI.SslOverTdsStream.Write (System.Byte[] buffer, System.Int32 offset, System.Int32 count) [0x0000f] in <fb2d0bc6c8f7446eaa3eaa0ac572f8d3>:0 at Mono.Net.Security.MobileAuthenticatedStream.<InnerWrite>b__86_0 () [0x00006] in <634e1667c20e48cfb6aa884228f8db67>:0 at System.Threading.Tasks.Task.InnerInvoke () [0x0000f] in <84c6975c2cbc47b489a2a76477d7a312>:0 at System.Threading.Tasks.Task.Execute () [0x00000] in <84c6975c2cbc47b489a2a76477d7a312>:0 --- End of stack trace from previous location where exception was thrown --- at Mono.Net.Security.MobileAuthenticatedStream.InnerWrite (System.Boolean sync, System.Threading.CancellationToken cancellationToken) [0x000d3] in <634e1667c20e48cfb6aa884228f8db67>:0 at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x00196] in <634e1667c20e48cfb6aa884228f8db67>:0 at Mono.Net.Security.AsyncProtocolRequest.StartOperation (System.Threading.CancellationToken cancellationToken) [0x0008b] in <634e1667c20e48cfb6aa884228f8db67>:0 --- End of inner exception stack trace --- at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x00252] in <634e1667c20e48cfb6aa884228f8db67>:0 <--- at System.Data.SqlClient.SqlInternalConnectionTds..ctor (System.Data.ProviderBase.DbConnectionPoolIdentity identity, System.Data.SqlClient.SqlConnectionString connectionOptions, System.Data.SqlClient.SqlCredential credential, System.Object providerInfo, System.String newPassword, System.Security.SecureString newSecurePassword, System.Boolean redirectedUserInstance, System.Data.SqlClient.SqlConnectionString userConnectionOptions, System.Data.SqlClient.SessionData reconnectSessionData, System.Boolean applyTransientFaultHandling) [0x00163] in <fb2d0bc6c8f7446eaa3eaa0ac572f8d3>:0 at System.Data.SqlClient.SqlConnectionFactory.CreateConnection (System.Data.Common.DbConnectionOptions options, System.Data.Common.DbConnectionPoolKey poolKey, System.Object poolGroupProviderInfo, System.Data.ProviderBase.DbConnectionPool pool, System.Data.Common.DbConnection owningConnection, System.Data.Common.DbConnectionOptions userOptions) [0x00144] in <fb2d0bc6c8f7446eaa3eaa0ac572f8d3>:0 at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection (System.Data.ProviderBase.DbConnectionPool pool, System.Data.Common.DbConnection owningObject, System.Data.Common.DbConnectionOptions options, System.Data.Common.DbConnectionPoolKey poolKey, System.Data.Common.DbConnectionOptions userOptions) [0x0000c] in <fb2d0bc6c8f7446eaa3eaa0ac572f8d3>:0 at System.Data.ProviderBase.DbConnectionPool.CreateObject (System.Data.Common.DbConnection owningObject, System.Data.Common.DbConnectionOptions userOptions, System.Data.ProviderBase.DbConnectionInternal oldConnection) [0x00184] in <fb2d0bc6c8f7446eaa3eaa0ac572f8d3>:0 at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest (System.Data.Common.DbConnection owningObject, System.Data.Common.DbConnectionOptions userOptions, System.Data.ProviderBase.DbConnectionInternal oldConnection) [0x00040] in <fb2d0bc6c8f7446eaa3eaa0ac572f8d3>:0 at System.Data.ProviderBase.DbConnectionPool.TryGetConnection (System.Data.Common.DbConnection owningObject, System.UInt32 waitForMultipleObjectsTimeout, System.Boolean allowCreate, System.Boolean onlyOneCheckConnection, System.Data.Common.DbConnectionOptions userOptions, System.Data.ProviderBase.DbConnectionInternal& connection) [0x000a4] in <fb2d0bc6c8f7446eaa3eaa0ac572f8d3>:0 at System.Data.ProviderBase.DbConnectionPool.WaitForPendingOpen () [0x00092] in <fb2d0bc6c8f7446eaa3eaa0ac572f8d3>:0 --- End of stack trace from previous location where exception was thrown --- at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnectionAsync (System.Boolean errorsExpected, System.Threading.CancellationToken cancellationToken) [0x000f9] in <c486d2adb419411a9a11f423095801e5>:0 at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync (System.Threading.CancellationToken cancellationToken, System.Boolean errorsExpected) [0x0009b] in <c486d2adb419411a9a11f423095801e5>:0 at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1+AsyncEnumerator[T].BufferlessMoveNext (Microsoft.EntityFrameworkCore.DbContext _, System.Boolean buffer, System.Threading.CancellationToken cancellationToken) [0x00098] in <c486d2adb419411a9a11f423095801e5>:0 at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.ExecuteAsync[TState,TResult] (TState state, System.Func`4[T1,T2,T3,TResult] operation, System.Func`4[T1,T2,T3,TResult] verifySucceeded, System.Threading.CancellationToken cancellationToken) [0x00089] in <70780d57b1e644f080d08b633fa994bf>:0 at Microsoft.EntityFrameworkCore.Query.Internal.AsyncQueryingEnumerable`1+AsyncEnumerator[T].MoveNext (System.Threading.CancellationToken cancellationToken) [0x00135] in <c486d2adb419411a9a11f423095801e5>:0 at System.Linq.AsyncEnumerable.SingleOrDefault_[TSource] (System.Collections.Generic.IAsyncEnumerable`1[T] source, System.Threading.CancellationToken cancellationToken) [0x000d7] in <afef21b57ad6402f8df4c5299ba699e2>:0 at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider+TaskResultAsyncEnumerable`1+Enumerator[T].MoveNext (System.Threading.CancellationToken cancellationToken) [0x00075] in <e66a1f96e9734a7fac7cea0901022728>:0 at System.Linq.AsyncEnumerable+SelectEnumerableAsyncIterator`2[TSource,TResult].MoveNextCore (System.Threading.CancellationToken cancellationToken) [0x000a6] in <afef21b57ad6402f8df4c5299ba699e2>:0 at System.Linq.AsyncEnumerable+AsyncIterator`1[TSource].MoveNext (System.Threading.CancellationToken cancellationToken) [0x00101] in <afef21b57ad6402f8df4c5299ba699e2>:0 at Microsoft.EntityFrameworkCore.Query.Internal.AsyncLinqOperatorProvider+ExceptionInterceptor`1+EnumeratorExceptionInterceptor[T].MoveNext (System.Threading.CancellationToken cancellationToken) [0x00143] in <e66a1f96e9734a7fac7cea0901022728>:0 at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteSingletonAsyncQuery[TResult] (Microsoft.EntityFrameworkCore.Query.QueryContext queryContext, System.Func`2[T,TResult] compiledQuery, Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger`1[TLoggerCategory] logger, System.Type contextType) [0x000d6] in <e66a1f96e9734a7fac7cea0901022728>:0 at Life_Programmer.Services.DatabaseServices.DatabaseHandler.LoginUser (System.String email, System.String password) [0x00108] in C:\Users\Meydan\source\repos\Life_Programmer\Life_Programmer\Life_Programmer\Services\DatabaseServices\DatabaseHandler.cs:43 ClientConnectionId:7453d528-808d-4249-b0db-ee7d31c86008}
EDIT2:
If I handle the exception so the application won't crash, then after the first try it works as expected.
So the problem occurs only on the first login try, and only with Android.
I changed the way my app communicates with the database and the problem got solved, instead of communicating from my app directly to the database I'm communicating to it through a web API.

SimpleInjector and Microsoft Webhook ASP.Net Webhooks

We had been successfully using the Microsoft ASP.Net Webhooks (specifically the Stripe one) in our WebAPI 2 project with Ninject. Recently we migrated to SimpleInjector and while everything else went well, we cannot get this webhook processor to work. It keeps throwing the following exception: System.MissingMethodException: 'No parameterless constructor defined for this object.'
The relevant stack traces are:
mscorlib.dll!System.RuntimeType.CreateInstanceSlow(bool publicOnly, bool skipCheckThis, bool fillCache, ref System.Threading.StackCrawlMark stackMark) Unknown
mscorlib.dll!System.Activator.CreateInstance(System.Type type, bool nonPublic) Unknown
mscorlib.dll!System.Activator.CreateInstance(System.Type type) Unknown
Microsoft.AspNet.WebHooks.Common.dll!Microsoft.AspNet.WebHooks.Utilities.TypeUtilities.GetInstances<Microsoft.AspNet.WebHooks.IWebHookHandler>(System.Collections.Generic.IEnumerable<System.Reflection.Assembly> assemblies, System.Func<System.Type, bool> predicate) Unknown
Microsoft.AspNet.WebHooks.Receivers.dll!Microsoft.AspNet.WebHooks.ReceiverServices.GetHandlers() Unknown
Microsoft.AspNet.WebHooks.Receivers.dll!Microsoft.AspNet.WebHooks.DependencyScopeExtensions.GetHandlers(System.Web.Http.Dependencies.IDependencyScope services = {SimpleInjector.Integration.WebApi.SimpleInjectorWebApiDependencyResolver}) Unknown
Microsoft.AspNet.WebHooks.Receivers.dll!Microsoft.AspNet.WebHooks.WebHookReceiver.ExecuteWebHookAsync(string id = "", System.Web.Http.Controllers.HttpRequestContext context = {System.Web.Http.WebHost.WebHostHttpRequestContext}, System.Net.Http.HttpRequestMessage request = {System.Net.Http.HttpRequestMessage}, System.Collections.Generic.IEnumerable<string> actions = {string[1]}, object data = {Newtonsoft.Json.Linq.JObject}) Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<Microsoft.AspNet.WebHooks.WebHookReceiver.<ExecuteWebHookAsync>d__22>(ref Microsoft.AspNet.WebHooks.WebHookReceiver.<ExecuteWebHookAsync>d__22 stateMachine) Unknown
Microsoft.AspNet.WebHooks.Receivers.dll!Microsoft.AspNet.WebHooks.WebHookReceiver.ExecuteWebHookAsync(string id, System.Web.Http.Controllers.HttpRequestContext context, System.Net.Http.HttpRequestMessage request, System.Collections.Generic.IEnumerable<string> actions, object data) Unknown
Microsoft.AspNet.WebHooks.Receivers.Stripe.dll!Microsoft.AspNet.WebHooks.StripeWebHookReceiver.ReceiveAsync(string id = "", System.Web.Http.Controllers.HttpRequestContext context = {System.Web.Http.WebHost.WebHostHttpRequestContext}, System.Net.Http.HttpRequestMessage request = {System.Net.Http.HttpRequestMessage}) Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<Microsoft.AspNet.WebHooks.StripeWebHookReceiver.<ReceiveAsync>d__15>(ref Microsoft.AspNet.WebHooks.StripeWebHookReceiver.<ReceiveAsync>d__15 stateMachine) Unknown
Microsoft.AspNet.WebHooks.Receivers.Stripe.dll!Microsoft.AspNet.WebHooks.StripeWebHookReceiver.ReceiveAsync(string id, System.Web.Http.Controllers.HttpRequestContext context, System.Net.Http.HttpRequestMessage request) Unknown
Microsoft.AspNet.WebHooks.Receivers.dll!Microsoft.AspNet.WebHooks.Controllers.WebHookReceiversController.ProcessWebHook(string webHookReceiver = "stripe", string id = "") Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<Microsoft.AspNet.WebHooks.Controllers.WebHookReceiversController.<ProcessWebHook>d__3>(ref Microsoft.AspNet.WebHooks.Controllers.WebHookReceiversController.<ProcessWebHook>d__3 stateMachine) Unknown
Microsoft.AspNet.WebHooks.Receivers.dll!Microsoft.AspNet.WebHooks.Controllers.WebHookReceiversController.ProcessWebHook(string webHookReceiver, string id) Unknown
[Lightweight Function]
System.Web.Http.dll!System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.GetExecutor.AnonymousMethod__8(object instance, object[] methodParameters) Unknown
System.Web.Http.dll!System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(System.Web.Http.Controllers.HttpControllerContext controllerContext, System.Collections.Generic.IDictionary<string, object> arguments, System.Threading.CancellationToken cancellationToken) Unknown
System.Web.Http.dll!System.Web.Http.Controllers.ApiControllerActionInvoker.InvokeActionAsyncCore(System.Web.Http.Controllers.HttpActionContext actionContext = {System.Web.Http.Controllers.HttpActionContext}, System.Threading.CancellationToken cancellationToken = IsCancellationRequested = false) Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0>(ref System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0 stateMachine) Unknown
System.Web.Http.dll!System.Web.Http.Controllers.ApiControllerActionInvoker.InvokeActionAsyncCore(System.Web.Http.Controllers.HttpActionContext actionContext, System.Threading.CancellationToken cancellationToken) Unknown
System.Web.Http.dll!System.Web.Http.Controllers.ApiControllerActionInvoker.InvokeActionAsync(System.Web.Http.Controllers.HttpActionContext actionContext, System.Threading.CancellationToken cancellationToken) Unknown
System.Web.Http.dll!System.Web.Http.Controllers.ActionFilterResult.ExecuteAsync(System.Threading.CancellationToken cancellationToken = IsCancellationRequested = false) Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2>(ref System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2 stateMachine) Unknown
System.Web.Http.dll!System.Web.Http.Controllers.ActionFilterResult.ExecuteAsync(System.Threading.CancellationToken cancellationToken) Unknown
System.Web.Http.dll!System.Web.Http.ApiController.ExecuteAsync(System.Web.Http.Controllers.HttpControllerContext controllerContext, System.Threading.CancellationToken cancellationToken) Unknown
System.Web.Http.dll!System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(System.Net.Http.HttpRequestMessage request = {System.Net.Http.HttpRequestMessage}, System.Threading.CancellationToken cancellationToken = IsCancellationRequested = false) Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1>(ref System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1 stateMachine) Unknown
System.Web.Http.dll!System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Unknown
System.Net.Http.dll!System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Unknown
System.Web.Http.dll!System.Web.Http.Dispatcher.HttpRoutingDispatcher.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Unknown
System.Net.Http.dll!System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Unknown
System.Web.Http.Cors.dll!System.Web.Http.Cors.CorsMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage request = {System.Net.Http.HttpRequestMessage}, System.Threading.CancellationToken cancellationToken = IsCancellationRequested = false) Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<System.Web.Http.Cors.CorsMessageHandler.<SendAsync>d__0>(ref System.Web.Http.Cors.CorsMessageHandler.<SendAsync>d__0 stateMachine) Unknown
System.Web.Http.Cors.dll!System.Web.Http.Cors.CorsMessageHandler.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Unknown
System.Net.Http.dll!System.Net.Http.DelegatingHandler.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Unknown
System.Web.Http.dll!System.Web.Http.HttpServer.SendAsync(System.Net.Http.HttpRequestMessage request = {System.Net.Http.HttpRequestMessage}, System.Threading.CancellationToken cancellationToken = IsCancellationRequested = false) Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<System.Web.Http.HttpServer.<SendAsync>d__0>(ref System.Web.Http.HttpServer.<SendAsync>d__0 stateMachine) Unknown
System.Web.Http.dll!System.Web.Http.HttpServer.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Unknown
System.Net.Http.dll!System.Net.Http.HttpMessageInvoker.SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) Unknown
System.Web.Http.WebHost.dll!System.Web.Http.WebHost.HttpControllerHandler.ProcessRequestAsyncCore(System.Web.HttpContextBase contextBase = {System.Web.HttpContextWrapper}) Unknown
mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start<System.Web.Http.WebHost.HttpControllerHandler.<ProcessRequestAsyncCore>d__0>(ref System.Web.Http.WebHost.HttpControllerHandler.<ProcessRequestAsyncCore>d__0 stateMachine) Unknown
System.Web.Http.WebHost.dll!System.Web.Http.WebHost.HttpControllerHandler.ProcessRequestAsyncCore(System.Web.HttpContextBase contextBase) Unknown
System.Web.dll!System.Web.TaskAsyncHelper.BeginTask(System.Func<System.Threading.Tasks.Task> taskFunc, System.AsyncCallback callback, object state = null) Unknown
System.Web.dll!System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() Unknown
System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step = {System.Web.HttpApplication.CallHandlerExecutionStep}, ref bool completedSynchronously = false) Unknown
System.Web.dll!System.Web.HttpApplication.PipelineStepManager.ResumeSteps(System.Exception error) Unknown
System.Web.dll!System.Web.HttpApplication.BeginProcessRequestNotification(System.Web.HttpContext context, System.AsyncCallback cb) Unknown
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNotificationPrivate(System.Web.Hosting.IIS7WorkerRequest wr = {System.Web.Hosting.IIS7WorkerRequest}, System.Web.HttpContext context = {System.Web.HttpContext}) Unknown
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext = 0x000002226c0521f0, System.IntPtr moduleData, int flags) Unknown
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags) Unknown
[Native to Managed Transition]
[Managed to Native Transition]
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags) Unknown
System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer, System.IntPtr nativeRequestContext, System.IntPtr moduleData, int flags) Unknown
[AppDomain Transition]
And
System.MissingMethodException: No parameterless constructor defined for this object.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.AspNet.WebHooks.Utilities.TypeUtilities.GetInstances[T](IEnumerable`1 assemblies, Func`2 predicate)
at Microsoft.AspNet.WebHooks.ReceiverServices.GetHandlers()
at Microsoft.AspNet.WebHooks.DependencyScopeExtensions.GetHandlers(IDependencyScope services)
at Microsoft.AspNet.WebHooks.WebHookReceiver.<ExecuteWebHookAsync>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.WebHooks.StripeWebHookReceiver.<ReceiveAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNet.WebHooks.Controllers.WebHookReceiversController.<ProcessWebHook>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()
Our global.asax looks like this:
var container = new Container();
container.Options.DefaultScopedLifestyle = new AsyncScopedLifestyle();
container.Options.PropertySelectionBehavior = new
InjectPropertySelectionBehavior();
// Register our stuff
container.RegisterMvcControllers(Assembly.GetExecutingAssembly());
container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
container.Verify();
GlobalConfiguration.Configuration.DependencyResolver = new
SimpleInjectorWebApiDependencyResolver(container);
DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container));
we're registering the WebHook handler like this:
container.Register<IWebHookHandler, StripeWebhookHandler>(Lifestyle.Singleton);
Has anyone gotten this to work with SimpleInjector? Or have any ideas what might be wrong?
Solution:
IWebhookHandler needs registered as a collection, so doing this:
container.Collection.Append(typeof(IWebHookHandler), typeof(StripeWebhookHandler));
instead of:
container.Register<IWebHookHandler, StripeWebhookHandler>(Lifestyle.Singleton);
was the trick!
I figured this out by stepping into the source of both the Microsoft Webhook assembly and SimpleInjector and found that when the Webhook assembly asked for all instances of type IWebhookHandler, SimpleInjector, in its GetServices implementation was trying to find all IEnumerable<IWebhookHandler> instead and so was coming up with nothing.
These kind of exceptions are thrown when trying to resolve a dependency that has parameter constructors but one or more of the parameters has not been registered and thus cannot be resolved, resulting in a fall back to a parameter-less constructor which in certain cases are absent.
Verify that you have registered all the components needed by WebHooks to work.

Self hosting nancy with razor returns empty body

Self hosting nancy with razor returns empty body.
I'm trying to self-host nancy in a console application with razor views, however I'm getting an empty body back.
It does work when running in IIS.
What I did:
I added all the appropriate razor configuration and build providers to the App.Config
I added a custom static root path provider, which seems to be configured well, as static files are served without a problem:
protected override IRootPathProvider RootPathProvider
{
get
{
if (ConfigurationManager.AppSettings["RootPath"].HasValue())
{
var path = Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).Directory.FullName, ConfigurationManager.AppSettings["RootPath"]);
return new StaticRootPathProvider(path);
}
return new DefaultRootPathProvider();
}
}
The razor view is found an being compiled, because when I add invalid code to the view, I do get a razor compiler error
When I debug with all exceptions caught, I get an exception on serving the page:
A first chance exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in Nancy.dll
Additional information: Cannot convert type 'Nancy.Responses.Negotiation.Negotiator' to 'Nancy.Response'
Nancy.dll!Nancy.Routing.DefaultRouteInvoker.CastResultToResponse(dynamic result) Unknown
Nancy.dll!Nancy.Routing.DefaultRouteInvoker.InvokeRouteWithStrategy(dynamic result, Nancy.NancyContext context) Unknown
Nancy.dll!Nancy.Routing.DefaultRouteInvoker.Invoke.AnonymousMethod__5(System.Threading.Tasks.Task completedTask) Unknown
Nancy.dll!Nancy.Helpers.TaskHelpers.WhenCompleted(System.Threading.Tasks.Task task, System.Action> onComplete, System.Action> onFaulted, bool execSync) Unknown
Nancy.dll!Nancy.Routing.DefaultRouteInvoker.Invoke(Nancy.Routing.Route route, System.Threading.CancellationToken cancellationToken, Nancy.DynamicDictionary parameters, Nancy.NancyContext context) Unknown
Nancy.dll!Nancy.Routing.DefaultRequestDispatcher.Dispatch.AnonymousMethod__0(System.Threading.Tasks.Task completedTask) Unknown
Nancy.dll!Nancy.Helpers.TaskHelpers.WhenCompleted(System.Threading.Tasks.Task task, System.Action> onComplete, System.Action> onFaulted, bool execSync) Unknown
Nancy.dll!Nancy.Routing.DefaultRequestDispatcher.Dispatch(Nancy.NancyContext context, System.Threading.CancellationToken cancellationToken) Unknown
Nancy.dll!Nancy.NancyEngine.InvokeRequestLifeCycle.AnonymousMethod__9(System.Threading.Tasks.Task t) Unknown
Nancy.dll!Nancy.Helpers.TaskHelpers.WhenCompleted(System.Threading.Tasks.Task task, System.Action> onComplete, System.Action> onFaulted, bool execSync) Unknown
Nancy.dll!Nancy.NancyEngine.InvokeRequestLifeCycle(Nancy.NancyContext context, System.Threading.CancellationToken cancellationToken, Nancy.Bootstrapper.IPipelines pipelines) Unknown
Nancy.dll!Nancy.NancyEngine.HandleRequest(Nancy.Request request, System.Func preRequest, System.Threading.CancellationToken cancellationToken) Unknown
Nancy.dll!Nancy.NancyEngineExtensions.HandleRequest(Nancy.INancyEngine nancyEngine, Nancy.Request request, System.Func preRequest) Unknown
Nancy.dll!Nancy.NancyEngineExtensions.HandleRequest(Nancy.INancyEngine nancyEngine, Nancy.Request request) Unknown
Nancy.Hosting.Self.dll!Nancy.Hosting.Self.NancyHost.Process(System.Net.HttpListenerContext ctx) Unknown
Nancy.Hosting.Self.dll!Nancy.Hosting.Self.NancyHost.GotCallback(System.IAsyncResult ar) Unknown
System.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken) Unknown
System.dll!System.Net.LazyAsyncResult.ProtectedInvokeCallback(object result, System.IntPtr userToken) Unknown
System.dll!System.Net.ListenerAsyncResult.IOCompleted(System.Net.ListenerAsyncResult asyncResult, uint errorCode, uint numBytes) Unknown
System.dll!System.Net.ListenerAsyncResult.WaitCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* nativeOverlapped) Unknown
mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP) Unknown
Then followed by a ArgumentNullException:
System.ArgumentNullException occurred
Message: A first chance exception of type 'System.ArgumentNullException' occurred in System.Web.dll
Additional information: Value cannot be null.
System.Web.dll!System.Web.HttpContextWrapper.HttpContextWrapper(System.Web.HttpContext httpContext) Unknown
System.Web.Optimization.dll!System.Web.Optimization.Styles.Context.get() Unknown
System.Web.Optimization.dll!System.Web.Optimization.Styles.RenderFormat(string tagFormat, string[] paths) Unknown
Temp_bfd13a3e77214eca9b1ce8f1a37d244d.dll!RazorOutput.RazorView.Execute() Unknown
Nancy.ViewEngines.Razor.dll!Nancy.ViewEngines.Razor.NancyRazorViewBase.ExecuteView(string body, System.Collections.Generic.IDictionary sectionContents) Unknown
[Lightweight Function]
Nancy.ViewEngines.Razor.dll!Nancy.ViewEngines.Razor.RazorViewEngine.RenderView.AnonymousMethod__26(System.IO.Stream stream) Unknown
Nancy.Hosting.Self.dll!Nancy.Hosting.Self.NancyHost.OutputWithDefaultTransferEncoding(Nancy.Response nancyResponse, System.Net.HttpListenerResponse response) Unknown
Nancy.Hosting.Self.dll!Nancy.Hosting.Self.NancyHost.ConvertNancyResponseToResponse(Nancy.Response nancyResponse, System.Net.HttpListenerResponse response) Unknown
Nancy.Hosting.Self.dll!Nancy.Hosting.Self.NancyHost.Process(System.Net.HttpListenerContext ctx) Unknown
Nancy.Hosting.Self.dll!Nancy.Hosting.Self.NancyHost.GotCallback(System.IAsyncResult ar) Unknown
System.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken) Unknown
System.dll!System.Net.LazyAsyncResult.ProtectedInvokeCallback(object result, System.IntPtr userToken) Unknown
System.dll!System.Net.ListenerAsyncResult.IOCompleted(System.Net.ListenerAsyncResult asyncResult, uint errorCode, uint numBytes) Unknown
System.dll!System.Net.ListenerAsyncResult.WaitCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* nativeOverlapped) Unknown
mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP) Unknown
UPDATE:
That last stack trace seems to imply a problem with AspNet.Web.Optimization, perhaps related to this question:
Can't get System.Web.Optimization to run with Nancy Self Hosting
I would strip everything out of the view accept for a span tag.
<span>Hello</span>
Also I would strip everything out of the bootstrapper except the lines
needed for razor.
If this works then you know something else is tripping it up.

Categories