System.Data.SQLite
View Ticket
Not logged in
Ticket UUID: 225968ceeedd9a465c0cd36cac98865074ec9b0e
Title: Better GetBaseDirectory for ASP.NET
Status: Closed Type: Feature_Request
Severity: Minor Priority: Medium
Subsystem: None Resolution: Works_As_Designed
Last Modified: 2014-01-23 01:57:59
Version Found In: 1.0.90.0
User Comments:
anonymous added on 2013-12-23 09:57:37:
x64/x32 folder is properly interpreted for desktop application. However ASP.NET looks for app\x64 while should look to app\bin\x64. Following methos is universal and works good for Desktop & ASP.NET context:

Assembly assembly = Assembly.GetExecutingAssembly();
if (assembly != null)
{
   Uri u = new Uri(assembly.EscapedCodeBase);
   String directory = Path.GetDirectoryName( u.LocalPath + Uri.UnescapeDataString(u.Fragment).Replace("/", @"\\") ) ;
   if (!String.IsNullOrEmpty(directory))
     return directory;
}

mistachkin added on 2013-12-23 14:47:17:
The currently supported alternative is to use the "PreLoadSQLite_BaseDirectory"
environment variable to manually override the base directory used by the native
library pre-loader.

mistachkin added on 2013-12-23 16:07:54:
An alternative "auto-detection" solution for ASP.NET would involve making use of
the HttpRuntime.UsingIntegratedPipeline, HttpRuntime.AppDomainAppVirtualPath, and
HttpContext.Current.Request.ApplicationPath properties.

mistachkin added on 2014-01-02 06:01:56:
See related ticket [f0246d1817].