-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InvalidProgramException: "Common Language Runtime detected an invalid program. (Dapper version:1.60.6) #2124
Comments
Unless you're talking about DapperAOT, regular vanilla Dapper doesn't have a bulk upsert feature; are you using "Dapper Plus" or similar? (Dapper Plus is a completely separate project with a different team, although Dapper Plus does help by sponsoring Dapper) If not: can you show what code you're using that I might investigate this? |
https://www.nuget.org/packages/Dapper/1.60.6 We are using the .net 6 web application, and I am using .netstandard dapper 1.60.6 |
Again, Dapper doesn't have bulk upsert features. And you haven't yet shown any code that shows what API in Dapper you're using. Please show some code that gives me a clue what method you're using in Dapper. Also, please post code and stack-traces as text, not images. |
bulk upsert internal method, getting the issue in the Execute method from Dapper
It is intermittent; I am trying to replicate and get logs with the full stack trace. |
Yep, the full stacktrace would be really helpful here. The only line I can see that involves Dapper here is the one:
but since this isn't using parameters, there's not actually anything for it to do re ref-emit, so: I'm not sure that's a likely cause. |
I have added the stack trace , below is the result 2024-10-17 13:54:41,154 [39] INFO Core.ORM.MySqlAdapter - Connection Opened: |
OK, so: whatever Core.ORM.MySqlAdapter.BulkUpsert is, it does seem to be calling through Dapper. Does this happen constantly, or only very occasionally. What would I need to reproduce this? Any minimal repro would be hugely helpful. |
yes, it is happening regularly, the sad part is it is happening only to specify Server (EC2) we are connecting AWS RDS. Other instances like local, dev,QA not able to reproduce this . that was very strange so reached for support .. it is happening only dapper and other DLLs are ok no such issue.. also it happens only in this method .. all other dapper methods we don't see |
Checking your screenshot: you're using a 5-and-a-half year old library version. It is possible that you're hitting a bug that has been fixed for years. Your first step here is to update the library version. If there's still a problem that needs fixing, we'd only be fixing it against "current" anyway, so: you'd need to do that to get any update. I suspect, however, that the problem will just go away. |
let me try your suggestion , it was on our road map but due to another internal dependency, we could not do that. let me push this suggestion and hopefully it is solves then well and good. |
I have upgraded the latest stable Dapper and mysqlconnector Nuget packages which did not help. I am experiencing the same issue. |
OK. Now; if I wanted to reproduce this in a minimal way - what would that look like. I can't guess all the code to make this happen. |
Option 1: Option 2: Some screen share session to review our code possible for you .. |
A minimal standalone repro ala "option 1" is hugely preferable - then we can investigate in isolation, without any PII or infosec concerns, and can leave an integration test as an outcome, so it never recurs. |
This error was resolved by replacing the EC2 image that the code was running on: mysql-net/MySqlConnector#1519 (comment) Seems highly likely to be environmental. |
2024-10-17 13:54:41,154 [39] INFO Core.ORM.MySqlAdapter - Connection Opened:
2024-10-17 13:54:41,155 [39] INFO Core.ORM.MySqlAdapter - Start Connection Execute with: CREATE TEMPORARY TABLE TmpIn_CMM_Role_Pages_6541bc52679842279c38e65b978d250b SELECT RoleID , PageName , USER_ACCESS , ADD_ACCESS , EDIT_ACCESS , DELETE_ACCESS , EXPORT_ACCESS , LAST_CHANGED_BY , LAST_CHANGED_ON FROM CMM_Role_Pages target LIMIT 0;:
2024-10-17 13:54:41,160 [39] ERROR Core.ORM.MySqlAdapter - Catch 2: System.InvalidProgramException: Common Language Runtime detected an invalid program.
at MySqlConnector.MySqlCommand.ExecuteNonQueryAsync(IOBehavior ioBehavior, CancellationToken cancellationToken)
at MySqlConnector.MySqlCommand.ExecuteNonQuery() in /_/src/MySqlConnector/MySqlCommand.cs:line 108
at Dapper.SqlMapper.ExecuteCommand(IDbConnection cnn, CommandDefinition& command, Action
2 paramReader) in C:\projects\dapper\Dapper\SqlMapper.cs:line 2827 at Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition& command) in C:\projects\dapper\Dapper\SqlMapper.cs:line 570 at Core.ORM.MySqlAdapter.BulkUpsert[T](IDbConnection connection, IDbTransaction transaction, IEnumerable
1 data, String tableName, Type type, Int32 bulkCopyTimeout, Nullable1 commandTimeout): 2024-10-17 13:54:41,161 [39] ERROR OCM.Utilities.SqlDataAccess - ExecuteBulkUpsertQuery:System.InvalidProgramException: Common Language Runtime detected an invalid program. at MySqlConnector.MySqlCommand.ExecuteNonQueryAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) at MySqlConnector.MySqlCommand.ExecuteNonQuery() in /_/src/MySqlConnector/MySqlCommand.cs:line 108 at Dapper.SqlMapper.ExecuteCommand(IDbConnection cnn, CommandDefinition& command, Action
2 paramReader) in C:\projects\dapper\Dapper\SqlMapper.cs:line 2827at Dapper.SqlMapper.ExecuteImpl(IDbConnection cnn, CommandDefinition& command) in C:\projects\dapper\Dapper\SqlMapper.cs:line 570
at Core.ORM.MySqlAdapter.BulkUpsert[T](IDbConnection connection, IDbTransaction transaction, IEnumerable
1 data, String tableName, Type type, Int32 bulkCopyTimeout, Nullable
1 commandTimeout)at Core.ORM.DapperExtensions.BulkUpsert[T](IDbConnection connection, IEnumerable
1 data, IDbTransaction transaction, Int32 batchSize, Int32 bulkCopyTimeout, Nullable
1 commandTimeout)at OCM.Utilities.SqlDataAccess.ExecuteBulkUpsertQuery[T](IEnumerable`1 obj)
The text was updated successfully, but these errors were encountered: