Executing a UWP application in DEBUG works perfectly.
Using exactly the same code compiled in RELEASE crashes with this error message 
System.PlatformNotSupportedException: 
    'Dynamic code generation is not supported on this platform.'
when executing this code (it's using Dapper 1.5.1 and System.Data.SQLite 1.0.109.2)
using (var c = NewConnection())
{
    var sql = @"
        update settings
        set
            ""value"" = @SetDate
        where ""key"" = 'week_date'";
    c.Execute(sql, new { SetDate = date }); //<= throws PlatformNotSupportedException 
                                            // only on RELEASE not in DEBUG
}
The application is UWP configured as below. Furthermore, the faulting code is a .NET Standard 2.0 Class Library

Why is it crashing on RELEASE only and how to fix it?
Dapper is very deeply based on runtime IL generation, in ways that it would be basically impossible to change. Runtime IL generation is fundamentally not compatible with UWP.
There is no simple way of making this work.
So: to do this, you'd need to use something dapper-like-but-not-dapper, with one of two alternative implementations:
Perhaps right now, the more pragamatic approach would be: don't use dapper in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With