MarkMpn / Sql4Cds

SQL 4 CDS core engine and XrmToolbox tool
MIT License
74 stars 22 forks source link

MarkMpn.Sql4Cds.Engine.Sql4CdsException: 'Common Language Runtime detected an invalid program.' #484

Closed sybaris closed 2 months ago

sybaris commented 3 months ago

Hi,

Using nuget 9.0.1 version, I have this exception : image

On the following code : image

Note that I do not have this issue on 8.0.1 nuget package.

Here the code :


            using (Sql4CdsConnection sqlConnection = new Sql4CdsConnection(ServiceClient))
            {
                using (var cmd = sqlConnection.CreateCommand())
                {
                    cmd.CommandText = @"select '%Object reference not set to an instance of an object%' as ExceptionName, 
                                           SUBSTRING(typename, 1, CHARINDEX(',', typename)-1) as TypeName, count(*) as Count
                                        from plugintracelog
                                        where createdon between '2024-06-04 00:00:00' and '2024-06-05 00:00:00'
                                        and  exceptiondetails like '%Object reference not set to an instance of an object%' 
                                        group by typename
                                        order by 3 desc
                                        ";
                    cmd.ExecuteReader();
                }
            }

Regards Sybaris

MarkMpn commented 2 months ago

This seems to be related to a difference between .NET Framework and .NET Core - the query runs as expected in .NET Framework but produces this error in .NET Core. I've opened an issue at https://github.com/dotnet/runtime/issues/103197 to see if this can be resolved properly in the .NET runtime, but in the meantime I've added a workaround for the next update.