I created a WebApp in Asp.Net Core 3.1 (Razor) with MySQL Database (8.0.36 Community Server).
I use:
- Hangfire 1.8.14
- MySQL Connector 2.3.7
- Pomelo.EFC.MySQL 5.0.4
dependencies
On my Index page I call a method that runs every 5 minute using HangFire.
When I call other methods, I get the following error:
Message: System.NullReferenceException: ‘Object reference not set to an instance of an object.
StackTrace: at MySqlConnector.MySqlDataReader.ActivateResultSet(CancellationToken cancellationToken) in /_/src/MySqlConnector/MySqlDataReader.cs:line 117
When I check mySqlException, is null and m_resultSet.ReadResultSetHeaderException.SourceException gives:
Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)
at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.GetResult(Int16 token)
at System.Net.Security.SslStream.<g__InternalFillBufferAsync|215_0>d1.MoveNext() at System.Net.Security.SslStream.<ReadAsyncInternal>d__214
1.MoveNext()
at MySqlConnector.Protocol.Serialization.StreamByteHandler.<g__DoReadBytesAsync|6_2>d.MoveNext() in //src/MySqlConnector/Protocol/Serialization/StreamByteHandler.cs:line 67
at MySqlConnector.Protocol.Serialization.BufferedByteReader.d__2.MoveNext() in //src/MySqlConnector/Protocol/Serialization/BufferedByteReader.cs:line 34
at MySqlConnector.Protocol.Serialization.ProtocolUtility.d__1.MoveNext() in //src/MySqlConnector/Protocol/Serialization/ProtocolUtility.cs:line 421
at MySqlConnector.Core.ServerSession.d__112.MoveNext() in //src/MySqlConnector/Core/ServerSession.cs:line 874
at MySqlConnector.Core.ResultSet.d__2.MoveNext() in /_/src/MySqlConnector/Core/ResultSet.cs:line 37
C#:
DateTime newDate = DateTime.Now;
bookings = (from i in await _context.BookingGroup2.ToListAsync().ConfigureAwait(false)
let d = DateTime.TryParseExact(i.Checkin, "yyyy-MM-dd HH:mm", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeLocal, out newDate)
where (((DateTimeFrom <= newDate) && (newDate <= DateTimeTo)) && (i.UserId == _userID))
orderby newDate ascending
select i).OrderBy(s => newDate).ToList();
bookingdetails = await _context.BookingDetails.Where(i => i.UserId == _userID && Regex.IsMatch(bids, "(?:^|,)" + i.OrderID.ToString() + "(?:,|$)")).OrderBy(i => i.FirstName).ThenBy(i => i.LastName).ToListAsync().ConfigureAwait(false); //if I skip all the errors, I end up to this line, the same happens in other methods too.
What I tried:
I tried to set await and async for all methods, but still gives error.
I created a SP in Mysql and tried to call with FromSQLRaw($’CALL …’), but the same happens.
TemNyilv is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.