locked
Accessing a Shared sqlite3 database Over Network under same or Different domain with Windows Service RRS feed

  • Question

  • Accessing a shared sqlite3 database over network under same or different domain from a Windows Service results to this error

    SQLite notice (27): delayed 1375ms for lock/sharing conflict at line 39194
    SQLite error (14): os_win.c:39201: (5) winOpen(\\SystemName\FolderName\file.sqlite3) - Access is denied.
    SQLite error (14): cannot open file at line 39210 of [bda77dda96]

    When this code is executed as an Console Application, it works fine, but when it is executed within an Windows Service the above exception is raised.


    • Moved by CoolDadTx Friday, April 29, 2016 3:24 PM Third party product
    Friday, April 29, 2016 10:42 AM

All replies

  • There are two main sources of issues with Services:

    - they run under sometimes very special (extremely limited) rights or user accounts. If so this would be a network/account rights problem.

    - they do not get an interactive session. That mostly is an issue with old COM Interop libraries, as those often need/expect interactive session. Office Interop suffers from it, for example:

    Interactive Services (Windows)

    http://stackoverflow.com/questions/2222365/what-is-a-message-pump#

    You can try out the workaround. But if it solves the issue, you should turn this programm away from a Windows Service altogether. The override should not be used for new programming. THe Windows Task Sheduler is usually a fitting alternative too Windows Services if you need a interactive session.



    Friday, April 29, 2016 11:50 AM
  • Access is denied.

    When this code is executed as an Console Application, it works fine, but when it is executed within an Windows Service the above exception is raised.

    The console application, a desktop solution, is running under the context of the logged in user account on the machine, which has the permissions to access the file.

    Where as, the Windows service is not using a user account that has the rights to access the file, which is most likely local/System account.

    Friday, April 29, 2016 12:30 PM
  • These forums are for MS products only. Questions related to SQLite should be posted in their forums. In fact their forums have a post about this very subject, it is not supported. Please post further questions about SQLite in their forums.
    Friday, April 29, 2016 3:22 PM
  • The Windows Service is calling that Console Application which is called using StartProcessAndBypassUAC Method.

    I tried with NetworkService Account and LocalSystem account. 

    If i try executing with NetworkService Account then the Service is unable to start the Application.

    If it is executed with LocalSystem Account then the Exception of Access is Denied arises.


    Monday, May 2, 2016 5:39 AM
  • This question is for MS product.

    As the same code works with Console Application on Network, so why it doesn't work with Windows Service on Network.


    Monday, May 2, 2016 5:48 AM
  • The Windows Service is calling that Console Application which is called using StartProcessAndBypassUAC Method.

    I tried with NetworkService Account and LocalSystem account. 

    If i try executing with NetworkService Account then the Service is unable to start the Application.

    If it is executed with LocalSystem Account then the Exception of Access is Denied arises.


    If you start the application as local system account and it tries to access a network resource, of course local system needs the rights to access said network resource.

    This is either a SQLITE or Network/Administration problem. In neither case does it look even remotely related to C# programming, .NET, Windows Services or Console Aplications.

    Monday, May 2, 2016 8:31 AM
  • #Christopher84, The same code is running When it is executed independently over Network as Console Application. 

    The problem is only when it is used as Service

     
    Monday, May 2, 2016 8:38 AM
  • Your post title asks how to do something that isn't supported. It doesn't matter whether you got it working (for now) in a console app or not. SQLite wasn't designed for this. If it is even remotely network aware it may simply fail multiple calls at the same time. However more likely you're going to get random errors including access denied, corrupt data, etc. You are trying to solve a problem that isn't going to work.

    In regards to the actual question about running as a service, you will have this same issue with any network resources. Local System and Local Service do not have network access and therefore will not be able to connect to any network resources. The only service accounts that are valid for network resources is Network Service or a domain account. So to solve the network question, switch to Network Service and then ensure that you either use a UN/PWD with SQLite (if supported) or you have to give the machine name access. Alternatively using a domain account name with permissions will work.

    Monday, May 2, 2016 2:47 PM