radioman / greatmaps

GMap.NET - Great Maps for Windows Forms & Presentation
909 stars 409 forks source link

Access Violation error when SQLite's Open() method is executed. #145

Open metu opened 4 years ago

metu commented 4 years ago

Hi there,

Firstly thanks for contributing towards the open source community with such an awesome project. Secondly forgive me if I'm being vague with regards to this issue.

Background: I've recently tried to use your project in a .Net Standard Class Library project to calculate the distance on a route between two GPS coordinates.

Issue Every time I tried to run any GetRoute() command from MapProviders i.e. var route= GMapProviders.OpenStreetMap.GetRoute(intialPoint, finalPoint,false, false, 1); it would break with an Access Violation error with the error message Attempted to read or write protected memory. This is often an indication that other memory is corrupt..

This lead me to clone the repo and create a local Nuget Package with symbols that I could debug. The error I found occurred in the method GMap.NET.CacheProviders.SQLitePureImageCache.CreateEmptyDB(string file) and more specifically on line 295of the class when the code cn.Open(); was executed.

Conclusion: I believe the issues is that SQLite was failing to create a database file when one didn't exist. I've looked on the net for solutions regarding this issue but the Access Violation error seems to be a vague one. The one solution I found from some post from the official SQLite team (not sure what blog or forum it was on again) was that they recommend that developers install their official Nuget package instead of making use of your system's DLL.

I've done that and thankfully the issue was resolved. I'll submit a Pull Request shortly.