Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Xamarin中的SQLite在连接中引发异常_C#_Sqlite_Xamarin_Xamarin.ios_Xamarin.android - Fatal编程技术网

C# Xamarin中的SQLite在连接中引发异常

C# Xamarin中的SQLite在连接中引发异常,c#,sqlite,xamarin,xamarin.ios,xamarin.android,C#,Sqlite,Xamarin,Xamarin.ios,Xamarin.android,我有个问题。我在iOS和Android应用程序中使用Xamarin。但是当我试图建立到文件夹路径的连接时,它总是抛出一个异常。这是我的代码: 公共类查询 { 私有字符串文件夹=DependencyService.Get().GetAppDataFolder() 例外情况是这样说的: 未处理的异常: System.TypeInitializationException:>'SQLite.SQLiteConnection'的类型初始值设定项引发异常。发生错误 我刚刚将尝试访问createDataBa

我有个问题。我在iOS和Android应用程序中使用Xamarin。但是当我试图建立到文件夹路径的连接时,它总是抛出一个异常。这是我的代码: 公共类查询 { 私有字符串文件夹=DependencyService.Get().GetAppDataFolder()

例外情况是这样说的:

未处理的异常:

System.TypeInitializationException:>'SQLite.SQLiteConnection'的类型初始值设定项引发异常。发生错误

我刚刚将尝试访问createDataBase方法的代码移动到初始化工具栏的位置,并在应用程序中得到一个消息框:

在我使用Xamarin.Android中的SQLite.PCL的项目中,我使用以下方法获取数据库文件夹和文件位置:

String dbFolder = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/project_name/";
String dbFileName = "project_name.db";
String dbPath = dbFolder + dbFileName;
//To check if the database file exists: System.IO.File.Exists(dbPath);
//To delete the database file: System.IO.File.Delete(dbPath);
SQLiteConnection dbConn = new SQLiteConnection(dbPath);

在我使用Xamarin.Android中的SQLite.PCL的项目中,我使用以下方法获取数据库文件夹和文件位置:

String dbFolder = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/project_name/";
String dbFileName = "project_name.db";
String dbPath = dbFolder + dbFileName;
//To check if the database file exists: System.IO.File.Exists(dbPath);
//To delete the database file: System.IO.File.Delete(dbPath);
SQLiteConnection dbConn = new SQLiteConnection(dbPath);

异常是什么意思?什么时候发生的?在生成或运行时?就在运行时,当我在我的设备上部署它时。你能从调试输出中提供更多关于异常的详细信息吗?你使用哪个sqlite包?异常是什么时候发生的?在生成或运行时?就在运行时,当我在m上部署它时y设备能否提供调试输出中异常的更多详细信息?使用哪个sqlite包?
public class FileSystemServiceAndroid : IFileSystemService
{
    public string GetAppDataFolder()
    {
        return System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
    }
}
String dbFolder = Android.OS.Environment.ExternalStorageDirectory.AbsolutePath + "/project_name/";
String dbFileName = "project_name.db";
String dbPath = dbFolder + dbFileName;
//To check if the database file exists: System.IO.File.Exists(dbPath);
//To delete the database file: System.IO.File.Delete(dbPath);
SQLiteConnection dbConn = new SQLiteConnection(dbPath);