RTC Forums
November 24, 2024, 03:00:04 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: RTC (win) Service auto-shutdown  (Read 5624 times)
zsleo
RTC Expired
*
Posts: 80


« on: February 20, 2013, 07:33:48 AM »

I have an app that has been running as a non-service EXE for a few months.

I converted it to run as a Win Service. Still runs perfectly as a non-service EXE but when I start the win-service it shuts down immediately.

I have traced my problem as follows:
 I have a TADOConnection in the application and when the Open is called, the database connection starts, logs on successfully then the service stops.

I don't know if it is the RTC or ADO stopping the service.

There are no errors or exceptions being generated - there is a clean log off, disconnect from the MS SQL db (ADO) and stopping of the service.

Any ideas?

TIA

Zane
Logged
zsleo
RTC Expired
*
Posts: 80


« Reply #1 on: February 20, 2013, 07:38:52 AM »

... just as I sent posted the request I thought I should look at the Event Viewer....

"Service failed on start: CoInitialize has not been called"

Sorry....

Zane
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #2 on: February 20, 2013, 09:08:56 AM »

Using the rtcActiveX unit somewhere in your Project should fix that problem. The only purpose of that unit is to call "CoInizialize(nil)" for every RTC Thread when the Thread starts and "CoUninitialize" before the Thread stops. These calls are required when using ActiveX components.

Best Regards,
Danijel Tkalcec
Logged
zsleo
RTC Expired
*
Posts: 80


« Reply #3 on: February 20, 2013, 11:24:46 PM »

Thanks, Danijel.

I should have known there would be an rtcActiveX   Embarrassed

I fixed my issue by calling CoInitialize directly and including ActiveX.

Are you saying that if I include the rtcActiveX then I done need to call CoInitialize?

Regards,

Zane
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #4 on: February 20, 2013, 11:35:35 PM »

Correct. That is the purpose of the rtcActiveX unit. It adds a new handler to RTC Thread creation and destruction code, which makes sure that CoInitialize is called automatically for each RTC Thread after it is created and CoUninitialize before it is destroyed. This way, you don't need to call it every time before you need to use ActiveX controls from RTC events executed in background threads. And because the call is made only once for every thread, it will also cost less CPU time than it would if you are calling it manually.

Best Regards,
Danijel Tkalcec
Logged
zsleo
RTC Expired
*
Posts: 80


« Reply #5 on: February 20, 2013, 11:55:29 PM »

Thanks.

The change will be made today.

Regards

Zane
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.024 seconds with 16 queries.