ericsink / SQLitePCL.raw

A Portable Class Library (PCL) for low-level (raw) access to SQLite
Apache License 2.0
512 stars 106 forks source link

System.TypeLoadException: 'Could not load list of method overrides due to Method not found: int SQLitePCL.ISQLite3Provider.sqlite3_win32_set_directory(int,string)' #594

Closed edumolina1975 closed 2 months ago

edumolina1975 commented 2 months ago

Hello friend, I hope you're doing well.

I've been having this issue when running my project on devices with Android 11 and later.

System.TypeLoadException: 'Could not load list of method overrides due to Method not found: int SQLitePCL.ISQLite3Provider.sqlite3_win32_set_directory(int,string)'

Could you inform me where I might be going wrong? Thanks in advance!

Here is the list of packages added to the project: "Newtonsoft.Json" version="13.0.3" targetFramework="monoandroid11.0" "sqlite-net-pcl" version="1.9.172" targetFramework="monoandroid11.0" "SQLitePCLRaw.bundle_e_sqlite3" version="1.1.4" targetFramework="monoandroid11.0" "SQLitePCLRaw.bundle_green" version="2.1.2" targetFramework="monoandroid11.0" "SQLitePCLRaw.core" version="2.1.2" targetFramework="monoandroid11.0" "SQLitePCLRaw.lib.e_sqlite3" version="2.0.0" targetFramework="monoandroid11.0" "SQLitePCLRaw.lib.e_sqlite3.android" version="2.1.2" targetFramework="monoandroid11.0" "SQLitePCLRaw.provider.e_sqlite3" version="2.1.2" targetFramework="monoandroid11.0" "SQLitePCLRaw.provider.e_sqlite3.android" version="1.1.14" targetFramework="monoandroid11.0" "System.Buffers" version="4.5.1" targetFramework="monoandroid11.0" "System.Memory" version="4.5.5" targetFramework="monoandroid11.0" "System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="monoandroid11.0" "Xamarin.AndroidX.Annotation" version="1.2.0.1" targetFramework="monoandroid11.0" "Xamarin.AndroidX.Migration" version="1.0.8" targetFramework="monoandroid11.0" "Xamarin.AndroidX.MultiDex" version="2.0.1.8" targetFramework="monoandroid11.0"

ericsink commented 2 months ago

Hmmm. Obviously, the win32-specific call should not be involved or required on Android.

Your list of packages isn't showing up for some reason.

After that, I can think of several diagnostic questions I might ask to try to figure out what's going wrong, but they're the same questions that were in the issue template, so I'm not sure where to go from here.

edumolina1975 commented 2 months ago

"Newtonsoft.Json" version="13.0.3" targetFramework="monoandroid11.0" "sqlite-net-pcl" version="1.9.172" targetFramework="monoandroid11.0" "SQLitePCLRaw.bundle_e_sqlite3" version="1.1.4" targetFramework="monoandroid11.0" "SQLitePCLRaw.bundle_green" version="2.1.2" targetFramework="monoandroid11.0" "SQLitePCLRaw.core" version="2.1.2" targetFramework="monoandroid11.0" "SQLitePCLRaw.lib.e_sqlite3" version="2.0.0" targetFramework="monoandroid11.0" "SQLitePCLRaw.lib.e_sqlite3.android" version="2.1.2" targetFramework="monoandroid11.0" "SQLitePCLRaw.provider.e_sqlite3" version="2.1.2" targetFramework="monoandroid11.0" "SQLitePCLRaw.provider.e_sqlite3.android" version="1.1.14" targetFramework="monoandroid11.0" "System.Buffers" version="4.5.1" targetFramework="monoandroid11.0" "System.Memory" version="4.5.5" targetFramework="monoandroid11.0" "System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="monoandroid11.0" "Xamarin.AndroidX.Annotation" version="1.2.0.1" targetFramework="monoandroid11.0" "Xamarin.AndroidX.Migration" version="1.0.8" targetFramework="monoandroid11.0" "Xamarin.AndroidX.MultiDex" version="2.0.1.8" targetFramework="monoandroid11.0"

The problem previously reported, for some reason, stopped occurring after I reviewed all the packages. However, I am now facing another problem in the line below: var connection = new SQLiteConnection(ConnectionString, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create, false) ;

Error: System.DllNotFoundException: 'e_sqlite3 assembly: type: member:(null)'

edumolina1975 commented 2 months ago

Forgive me for insisting! I really need to solve this problem because I have been struggling with it for some time. I would be very grateful if you could help me! Please!

ericsink commented 2 months ago

Like I tried to explain above, I can't help you without more information, to figure out what's going wrong.

The first pieces of information I need are the answers to the questions in the issue template. But you are apparently unwilling to answer those questions. So I don't see any way to help you.

ericsink commented 2 months ago

Actually, it looks like I can give at least SOME help from the packages list.

You still have references to packages from SQLitePCLRaw 1.1.14. These should be removed.

It looks like you're still on packages.config, or converted from that. You don't need to explicitly list transitive packages. Try keeping bundle_green but remove all of SQLitePCLRaw.provider. and SQLitePCLRaw.lib.

edumolina1975 commented 2 months ago

Okay, sorry, but it wasn't very clear what information you need. I have resent the packages used as requested...

Anyway, I rolled back the packages to version 2.10 and set them to the same version across all projects. And it worked!

Thank you for your support and for the time you dedicated to me! It's always good to know that there is someone willing to help. It gives us more confidence. May God always bless you to continue with this work.

πŸ™πŸ™πŸ™

ericsink commented 2 months ago

Very good. So glad it's working for you now.

Unsolicited advice for the future: Whenever you ask an open source maintainer for help, always give LOTS of information and context. 😁

edumolina1975 commented 2 months ago

Hello my friend, I hope you're doing well...

Here I am again with a new problem...

However, I don't know what more detail I could provide... if you need more information, please ask me and I will send it to you.

I'll try to provide as much information as I can...

I have this method: public static IList QuerySQL(string sql, object[] args = null) where T : new() { lock (_lock) { var db = GetConnection();

    if (args == null)
        args = new object[] { };

    try
    {
        return db.Query<T>(sql, args); // <-- the error occurs here: System.ArgumentException: 'method arguments are incompatible' when executing
    }
    finally
    {
        DataAcessHelper.ReleaseConnection(db);
    }
}

}

The "args" parameter is empty, i.e., it was constructed with this line args = new object[] { };.

The select query I am running is this: ConfiguracaoEmailDTO ModuloVendas.Query.QueryParametros.IVendedorQuery.GetConfiguracaoEmail() { const string sql = @"SELECT Email AS Email, Usuario AS Usuario, Senha AS Senha, SMTP AS SMTP, Porta AS Porta, '' as POP, 0 as PortaPOP, PrecisaAutenticar AS PrecisaAutenticar, 0 AS UsarSsl, '' as EmailsPermitidos, '' as CopiasOculta FROM ConfigEmail";

var result = DataAcessHelper.QuerySQL<ConfiguracaoEmailDTO>(sql).FirstOrDefault();

return result;

}

I have checked the table in the database, and all fields exist. Here is the DDL of the table: CREATE TABLE "ConfigEmail" ( "Email" varchar, "Usuario" varchar, "Senha" varchar, "SMTP" varchar, "Porta" integer, "PrecisaAutenticar" varchar(1) );

The table has only one record in the database.

I would be extremely grateful if you could shed some light on the problem.

Below I list the packages and versions I am using. Here they are: "sqlite-net-pcl" version="1.9.172" targetFramework="monoandroid11.0" "SQLitePCLRaw.bundle_green" version="2.1.2" targetFramework="monoandroid11.0" "SQLitePCLRaw.core" version="2.1.2" targetFramework="monoandroid11.0" "SQLitePCLRaw.lib.e_sqlite3.android" version="2.1.2" targetFramework="monoandroid11.0" "SQLitePCLRaw.provider.e_sqlite3" version="2.1.2" targetFramework="monoandroid11.0" "System.Buffers" version="4.4.0" targetFramework="monoandroid11.0" "System.Memory" version="4.5.3" targetFramework="monoandroid11.0" "System.Runtime.CompilerServices.Unsafe" version="4.5.2" targetFramework="monoandroid11.0" "Xamarin.AndroidX.Annotation" version="1.2.0.1" targetFramework="monoandroid11.0" "Xamarin.AndroidX.Migration" version="1.0.8" targetFramework="monoandroid11.0" "Xamarin.AndroidX.MultiDex" version="2.0.1.8" targetFramework="monoandroid11.0"

ericsink commented 2 months ago

(1) In most repos and forums, it is considered good practice is to always start a new issue in a new issue. In other words, since this latest problem is probably unrelated to the first one, it would have been better if you opened a separate issue to discuss it. The main reason for this is so that it is possible to close issues when they are completed.

(2) Another problem with your latest question is that this repo is probably not the right place to ask. In other words, this new problem appears to be specific to sqlite-net, because Query<T>() is a method in that package, not in SQLitePCLRaw. The repo for sqlite-net is at https://github.com/praeclarum/sqlite-net

(3) That said, I wish I could give you a helpful answer anyway, but I'm not familiar with the API you're calling. It seems clear that Query<T>() doesn't like the args you are passing in, but I don't know what those args are for. I speculate they are things to be bound into substitution parameters for the SQL query, and the args you pass in need to be type-compatible with the corresponding SQL expressions. But I don't see any parameters in the SQL SELECT statement you included, so I'm not sure my guess is useful.

edumolina1975 commented 2 months ago

Okay my friend, forgive my ignorance and thank you very much for the guidance. I will follow your advice, as I am new to this type of communication via forums and therefore end up making these basic mistakes. I will check these issues more carefully, as I am certainly getting confused and that's why I've been having these problems. Once again, thank you very much.