none
C# Windows Service upgraded to .net 2.0 runs slower RRS feed

  • Question

  • We have 2 programs written in C#:

    1) Program A that does some processing. Written and compiled in .net 2.0.
    2) Program B that is a windows service (using serviceBase inheritance). Have both a .net 1.1 and .net 2.0 compiled copy.

    We used "installutil.exe" from the .net 2.0 location to install the service B.

    If we use .net 1.1 compiled files (program B) in the directory the service is looking at and restart the service, program A runs in approximately 10 seconds. If we copy the .net 2.0 compiled files (program B) into the directory the service is looking at and restart the service program A runs in about 5 minutes, significantly slower.

    Program A does do some compiling on the fly (VBCodeProvider) but it is the constant in this scenario so it shouldn't make a difference I would think. If we remove the need for compiling from progam A we still get a slower result but not as significant. ie. with .net 1.1 service A runs in 10 seconds and .net 2.0 service A runs in 20 seconds with no compiling on the fly.

    Basically using a service written in .net 1.1 runs a program faster than a service written in .net 2.0.

    Any help would be greatly appreciated.

    Thanks Paul

    Thursday, December 10, 2009 6:19 AM

Answers

  • Paul,

    From what I understand (both the application A and the service B seem to function normally), I cannot see any reason for the huge delay when using a .NET 2.0 service instead of a 1.0 service. You should use a profiler to identify the root of your problem (or at least performance counters or some StopWatch etc.). Also, you could try to execute application B as a normal windows application to find out, if the problem is really service related.

    Marcel
    Friday, December 11, 2009 1:39 PM

All replies

  • Hi Paul,

    Is application A interacting with service B?
    Do you use any type of hidden window with your service?
    Do you use Applicaton.DoEvents(), ArrayList.Contains(), DataReader.Read()/DataAdapter?
    Are the results from application B correct?
    Have you used a profiler on the .NET 2.0 version?

    There have been some reports on performance issues with different areas of the .NET 2.0 framework. In most cases some performance was sacrificed to improve stability. You need to carefully asses the new capabilities of the .NET 2.0 framework. Compiling 1:1 code from v. 1.1 to v. 2.0 is a quick, but not optimal solution. There are so many areas where performance *has* improved in .NET 2.0!

    Marcel

    Thursday, December 10, 2009 10:01 AM
  • Service B is starting off the running of application A and also monitoring its progress through the process thats starts it. The Process created does redirect standard input, output and errors.

    No hidden windows used.

    Don't use Application.DoEvents() etc.

    Results from application A are correct. Sometimes application A fails to run (have not had this recently so can't recall why this happened)

    Not used profiler.

    The performance sacrified here to upgrade to 2.0 via the wizard in visual studio is far too great, this is only a small example. Other examples have blown out from a few minutes to hours which is not acceptable.

    Any other way I could upgrade the service (B) to 2.0 and what to look for to change in the service to improve performance. Could it have to do with the serviceBase class that is implemented as this is our guess as to where the problem is lying.

    Any help is greatly appreciated.

    Thanks Paul
    Thursday, December 10, 2009 10:44 PM
  • Paul,

    From what I understand (both the application A and the service B seem to function normally), I cannot see any reason for the huge delay when using a .NET 2.0 service instead of a 1.0 service. You should use a profiler to identify the root of your problem (or at least performance counters or some StopWatch etc.). Also, you could try to execute application B as a normal windows application to find out, if the problem is really service related.

    Marcel
    Friday, December 11, 2009 1:39 PM
  • Have not used profiler but will give it a go. When using application A without the service it runs fast (10 sec), same speed as using it with the 1.1 service.

    Will have to just try some more stuff, we also cannot see any reason why a 2.0 service would run a program slower than a 1.1 service.

    Thanks
    Sunday, December 13, 2009 10:32 PM