如何避免Unhandled Exception:System.EntryPointNotFoundException:在monodroid中

时间:2012-06-20 07:19:38

标签: sqlite xamarin.android

我正在使用以下代码

创建数据库oncreate

 private void chech_database_exist_or_not()
    {

        string dbPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "validation.db3");
        bool exists = File.Exists(dbPath);
        if (!exists)
            SqliteConnection.CreateFile(dbPath);
        var connection = new SqliteConnection("Data Source=" + dbPath);
        connection.Open();
        if (!exists)
        {
            // This is the first time the app has run and/or that we need the DB.
            // Copy a "template" DB from your assets, or programmatically create one.
            var commands = new[]{

      "CREATE TABLE [user_detail] (_id integer NOT NULL PRIMARY KEY AUTOINCREMENT,user_name varchar,pass varchar,designation varchar,email varchar);",

    "insert into user_detail(user_name,pass) values('testuser','testpass') "


            };
            foreach (var command in commands)
            {
                using (var c = connection.CreateCommand())
                {
                    c.CommandText = command;
                    c.ExecuteNonQuery();
                }
            }
        }

        connection.Close();


    }

按钮单击我调用功能

    private  bool validate_user(string username, string password)
    {
        bool i;
        i = true;
        string str;



        DataTable dt = new DataTable();
        string dbPath1 = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "validation.db3");

        SqliteConnection con = new SqliteConnection("Data Source=" + dbPath1);
        str = "select pass from user_detail where user_name='" + username + "' and pass='" + password + "'";
        SqliteCommand cmd = new SqliteCommand(str, con);
       // SqliteDataAdapter da = new SqliteDataAdapter(cmd);

        FillDatatable(cmd, dt);






        if (dt != null)
        {
            if (dt.Rows.Count > 0)
            {
                i = true;

            }
            else
            {
                i = false;
            }

        }
        else
        {
            i = false;
        } 

        return i;

    }

我使用的课程

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.OS;
using Mono.Data.Sqlite;
using System.Data;
using System.IO;
using Android.InputMethodServices;

任何人都可以帮助我为什么会收到此错误以及我如何克服它?

1 个答案:

答案 0 :(得分:0)

取自this question的回答:

  

不幸的是,Android的SQLite库不支持   sqlite3_column_origin_name()方法,因此Mono.Data.Sqlite的任何部分   依赖它会失败。 Xamarin跟踪了一个bug   here用于修改实现以绕过   限制,但据我所知,目前尚无时间表。

问题中的代码不包括FillDatatable()的实现,但我猜测已知有此问题的调用DataTable.Fill()。目前的解决方法基本上只是为了避免使用依赖于Android中缺少此功能的ADO.NET部分,例如DataTable.Fill()