0

I am just curious to know if at all there is any technical/theoretical reasons for a windows NT service to be more stable that created with c++ rather than .Net application or vice versa.

Actually I had two Nt Services one made with cpp and other with .Net application. I observe both as showing in start mode but I need to restart service created by .Net often(on average once every 2 days) to respond. When I tried to know about this strange behavior of .Net service some of my friends come up with answers related to OS internals and some say .Net was build like that. I am totally unaware of .Net platform so in finding the reason this forum is one of my attempt.

Thanks

Anil

Anil Kumar
  • 493
  • 5
  • 16
  • In what way more stable? – Bali C Apr 25 '12 at 14:27
  • 8
    both are as stable as the programmer creates them – Roger Apr 25 '12 at 14:28
  • 1
    You would probably gain some performance with C++ (if it is native) than with .NET, but this would be only during the startup. Once they are both up and running, there shouldn't be much of a difference. – Huske Apr 25 '12 at 14:31
  • @Roger - You are right but i am looking for some inner details if present that could elevate advantage of c/c++ over .Net or vice versa. – Anil Kumar Apr 25 '12 at 14:38
  • @Anil Kumar, see the comment by Huske. And consider to update/edit your question since the number of downvotes indicates this is not a 'good' question. Check out the FAQ for more information on how to ask questions: http://stackoverflow.com/faq#dontask – Roger Apr 25 '12 at 14:43
  • 1
    Though it wasn't phrased about services (which are pretty much irrelevant), this is basically a duplicate of a [previous question about C# vs. C++](http://stackoverflow.com/questions/5326269/is-c-sharp-really-slower-than-say-c) – Jerry Coffin Apr 25 '12 at 14:45
  • @Roger - thanks for highlighting that point to me, I kept the reason why i asked this question - its a practical problem i face – Anil Kumar Apr 25 '12 at 14:53
  • Thanks Jerry Coffin, I am looking for such links/answers – Anil Kumar Apr 25 '12 at 14:56
  • 1
    Having worked in an organization that uses __very high performance__ Windows services written both in C++ and .NET one of the drawbacks of the .NET services were that garbage collection could kick in unexpectedly and make the service unresponsive for several seconds. By carefully designing your service you should be able to avoid this problem but it can be non-trivial. On the other hand C++ services in general are harder to write and if badly written will leak memory, crash in crazy ways and be hard to maintain. – Martin Liversage Apr 25 '12 at 15:03

2 Answers2

2

You would probably gain some performance with C++ (if it is native) than with .NET, but this would be only during the startup. Once they are both up and running, there shouldn't be much of a difference.

However, creating a service through native C++ (as far as I can remembe now) was really pain and it took quite a bit of time. With .NET it is much easier and faster. To be honest, I never had a need to create some super important high speed service. I have created quite a number of services in .NET and they successfully do their job. In these cases the business end result was more important than the actual performance.

It is really all about your needs, but as someone said in the comment, the service will be as stable as the programmer wrote it. If you are more comfortable creating a service for controlling a nuclear reactor in .NET, do it in .NET. :-)

Huske
  • 9,186
  • 2
  • 36
  • 53
2

The C++ Service, or any win32 executable, will continue to work across multiple versions of windows, both future and past. This gives win32 longevity and near immunity to changes in the server. Your C++ service will likely not have very many, or none at all, dependencies on anything installed on the server. This reduces the number of points of failure.

.Net applications are highly fragile and can cost a lot of money to repair a failed .net application. The fragilness comes from an application being finicky on the version of .net framework installed on the server. Microsoft has a short lifespan on .net versions. .Net has lots of dependencies that increase points of failure such as a high number or assembly files and sensitive config files.

In conclusion, C++/Win32 will be much more stable due to the stability of win32 and having much fewer dependencies.

William Egge
  • 429
  • 4
  • 5