dapper.contrib xamarin.android System.MissingMethodException: Method 'SecurityCriticalAttribute..ctor' not found.
We use dapper 1.50.2 with Xamarin.android and it works great .
it is even possible to use it, in a pcl library by referencing the dapper DLL.
In the project xamarin.android you no longer need to specify Dapper everything happens in the core / pcl .
Attention in the PCL , you must reference .net framework 4.5 and not 1.3
Dapper.contrib works the same way.
In an old Xamarin android project we want to add Dapper.contrib . But we meet each time an error when running
{System.MissingMethodException: Method 'SecurityCriticalAttribute..ctor' not found. at (wrapper managed-to-native) System.MonoCustomAttrs:GetCustomAttributesDataInternal (System.Reflection.ICustomAttributeProvider) at System.MonoCustomAttrs.GetCustomAttributesData ...
My sample :
// requete with Dapper -> Ok return one object structureFASSURANCE
var sql = " select * from fassurance ";
var xx = idb.QueryFirstOrDefault<CorePcl.Database.structureFASSURANCE>(sql);
// insert with dapper -> Ok - with just 3 fields line created
sql = " insert into fassurance ( id,ASS_CODE,deleted ) values ('4567','titi',0)";
idb.Execute(sql);
// insert with dapper.contrib and we use the first object return by dapper -> not ok : {System.MissingMethodException: Method 'SecurityCriticalAttribute..ctor' not found.
xx.id = "1234";
xx.ASS_CODE = "toto";
xx.deleted = 0;
var idlg = idb.Insert<CorePcl.Database.structureFASSURANCE>(xx);
I do not understand the message, and I do not know what to do or authorize. In other projects I do not have the same problem.
This project also uses MVVMCROS but this is not a reason.
We integrated sources and dapper dapper.contrib in the project and the error appears in the GetName function.
public static long Insert<T>(this IDbConnection connection, T entityToInsert, IDbTransaction transaction = null, int? commandTimeout = null) where T : class
{
var isList = false;
var type = typeof(T);
if (type.IsArray)
{
isList = true;
type = type.GetElementType();
}
else if (type.IsGenericType())
{
isList = true;
type = type.GetGenericArguments()[0];
}
var name = GetTableName(type); <<<<<<<<<<<<<<< error
For all functions of Dapper.contrib the same error message (android listed or quoted pcl in the project or dll)
Looking for 2 days, but I do not see that changing
This was an issue with earlier targets of the library but isn't any longer today - closing out to tidy up!