Overview: I'm calling an Init method from my DatabaseHelper
class to init the SQLLite database attached to the solution. But when I call Init() I get an AccessViolationException
.
Question: How can I debug the AccessViolationException further? There isn't an inner exception in the error detail.
Error Log:(no inner exception on the error)
System.AccessViolationException was unhandled by user code
HResult=-2147467261
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=Parking Tag Picker WRT
StackTrace:
at Parking_Tag_Picker_WRT.ViewModel.TagRequestViewModel.<GetAllZoneInfoAsync>d__0.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Parking_Tag_Picker_WRT.ViewModel.TagRequestViewModel.GetAllZoneInfoAsync()
at Parking_Tag_Picker_WRT.TagRequestPage.OnNavigatedTo(NavigationEventArgs e)
at Parking_Tag_Picker_WRT.MainPage.Parking_Tag_Picker_WRT.Interfaces.INavigationCallback.NavigateTo(String ItemID)
at Parking_Tag_Picker_WRT.ViewModel.MainViewModel.set_SelectedCouncilName(CouncilName value)
Code: (During debugging it seems the Init method never gets called as debugger doesn't step into the helper class.
Calling method in VieModel -
public async Task GetAllZoneInfoAsync()
{
string dbPathValue;
int CouncilId = Int32.Parse(SelectedCouncilId);
dbPathValue = DBPathDictonary[CouncilId];
//Exception thrown here on the Init() call
IsConnected = await _dbHelper.Init(dbPathValue);
}
DBHelper Class -
namespace Parking_Tag_Picker_WRT.Helpers
{
public class DatabaseHelper
{
private SQLiteConnection dbConn;
/// <summary>
/// Load SQL_LiteTable from Solution
/// </summary>
/// <param name="DB_PATH"></param>
/// <returns></returns>
public async Task<bool> Init(string dbPath)
{
bool isDatabaseExisting = false;
try
{
StorageFile storageFile = await ApplicationData.Current.LocalFolder.GetFileAsync(dbPath);
isDatabaseExisting = true;
}
catch
{
isDatabaseExisting = false;
}
if (!isDatabaseExisting)
{
StorageFile databaseFile = await Package.Current.InstalledLocation.GetFileAsync(dbPath);
await databaseFile.CopyAsync(ApplicationData.Current.LocalFolder);
}
return true;
}
}
}
Aucun commentaire:
Enregistrer un commentaire