Instantiating SqlCeConnection object slow when running as a service.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mario Suau
    New Member
    • Oct 2008
    • 4

    #1

    Instantiating SqlCeConnection object slow when running as a service.

    I'm working on a C# server based application using Sql Compact 3.5 as the database. It's designed to run as a service. My problem is that when I run the service, the following line of code takes 15 seconds to execute:

    _dbConnection = new SqlCeConnection ();

    _dbConnection is declared as a SqlCeConnection inside of the class.

    I'm positive that this line is what's causing the delay because I've commented out all of the other code so that this is all that executes when the service starts up.

    I can run the app in another mode by specifying a command line argument and double clicking it. In this mode, it's obviously not a service and a debug window pops up with debug messages, etc. When I run it in this mode, instantiating the SqlCeConnection is instant.

    Does anyone know why it would be instant running as an app, but take 15 seconds when running as a service?

    Thanks,
    Mario
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    What type of service? Windows or Web.

    Comment

    • Mario Suau
      New Member
      • Oct 2008
      • 4

      #3
      It's a Windows service running on XP Pro SP 3.

      Thanks,
      Mario

      Comment

      • PRR
        Recognized Expert Contributor
        • Dec 2007
        • 750

        #4
        Originally posted by Mario Suau
        I'm working on a C# server based application using Sql Compact 3.5 as the database. It's designed to run as a service. My problem is that when I run the service, the following line of code takes 15 seconds to execute:

        _dbConnection = new SqlCeConnection ();

        _dbConnection is declared as a SqlCeConnection inside of the class.

        I'm positive that this line is what's causing the delay because I've commented out all of the other code so that this is all that executes when the service starts up.

        I can run the app in another mode by specifying a command line argument and double clicking it. In this mode, it's obviously not a service and a debug window pops up with debug messages, etc. When I run it in this mode, instantiating the SqlCeConnection is instant.

        Does anyone know why it would be instant running as an app, but take 15 seconds when running as a service?

        Thanks,
        Mario
        Windows service or Vista service runs under different account.. The GUI user account and service account have different rights... possibly you should look into that... also you could have a webservice in between database and your service... Your service can asynchronously call methods of web service...
        Anything that you do with a windows service ... for better results should be done asynchronouly.. ..
        As service run under restricted account ... maybe the security checks n other configuration are takin time?
        is it a local or remote database?

        Comment

        • Mario Suau
          New Member
          • Oct 2008
          • 4

          #5
          It's a local SQL CE database. I think you might be on to something as far as it running under a different account. As a service, it's running as the Local System account. I'm going to try a few things and I'll post if I come up with a solution.

          Thanks,
          Mario

          Comment

          • Mario Suau
            New Member
            • Oct 2008
            • 4

            #6
            I found my problem. I'm developing via remote desktop in a virtual environment and there must be some sort of permissions problem on the Local System account in that environment. I ran it on my local computer and the service starts up fine with no slowdown whatsoever.

            Thanks,
            Mario

            Comment

            Working...