Hi all,
I'm in the midst of writing a number of different service applications. I've developed a framework I'm happy with that involves a service having an Access database that's used for configuration settings and logging, and can also be used for whatever specific purpose that service application requires.
The code to handle logging, initializing, and reading/writing variables runs to a few hundred lines, so after copying these functions from project to project, making small changes along the way to improve things and having the first projects having older code, I thought I could easily make a descendant class of TService. So I did. Compiles and works great. Except when I went back and opened one of these projects that I'd converted to the new TService descendant, I started getting errors.
The errors related to published properties that weren't available, such as Display Name, which is a published property of TService. There were others as well. I clicked 'Ignore' to them, and noticed that my service application 'form', instead of looking like a TDatamodule form, now looks like a regular form.
I started from fresh with the most basic of code to see if I can replicate the error, and I can. This code:
produces the error. All I did was create a new service application, add the NuSvc reference, and change TService to TNuService. Compiles fine. Close, won't reload correctly.
Using Delphi 6. Everything looks as though it should work. It makes no sense that this shouldn't work, because all I'm doing is inserting my service class between TService1 and TService anyway.
Maybe I just need some fresh eyes and brains. Anyone got any clues?
I'm in the midst of writing a number of different service applications. I've developed a framework I'm happy with that involves a service having an Access database that's used for configuration settings and logging, and can also be used for whatever specific purpose that service application requires.
The code to handle logging, initializing, and reading/writing variables runs to a few hundred lines, so after copying these functions from project to project, making small changes along the way to improve things and having the first projects having older code, I thought I could easily make a descendant class of TService. So I did. Compiles and works great. Except when I went back and opened one of these projects that I'd converted to the new TService descendant, I started getting errors.
The errors related to published properties that weren't available, such as Display Name, which is a published property of TService. There were others as well. I clicked 'Ignore' to them, and noticed that my service application 'form', instead of looking like a TDatamodule form, now looks like a regular form.
I started from fresh with the most basic of code to see if I can replicate the error, and I can. This code:
Code:
[navy][i]{---- .DPR file ----}[/i][/navy]
[b]program[/b] Project1;
[b]uses[/b]
SvcMgr,
Unit1 [b]in[/b] [teal]'Unit1.pas'[/teal] [navy][i]{Service1: TService}[/i][/navy];
[navy][i]{$R *.RES}[/i][/navy]
[b]begin[/b]
Application.Initialize;
Application.CreateForm(TService1, Service1);
Application.Run;
[b]end[/b].
Code:
[navy][i]{---- .PAS file ----}[/i][/navy]
[b]unit[/b] Unit1;
[b]interface[/b]
[b]uses[/b]
Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs,
NuSvc; [navy][i]// added NuSvc reference
[/i][/navy]
[b]type[/b]
TService1 = [b]class[/b](TNuService) [navy][i]// changed from TService
[/i][/navy] [b]private[/b]
[navy][i]{ Private declarations }[/i][/navy]
[b]public[/b]
[b]function[/b] GetServiceController: TServiceController; [b]override[/b];
[navy][i]{ Public declarations }[/i][/navy]
[b]end[/b];
[b]var[/b]
Service1: TService1;
[b]implementation[/b]
[navy][i]{$R *.DFM}[/i][/navy]
[b]procedure[/b] ServiceController(CtrlCode: DWord); stdcall;
[b]begin[/b]
Service1.Controller(CtrlCode);
[b]end[/b];
[b]function[/b] TService1.GetServiceController: TServiceController;
[b]begin[/b]
Result := ServiceController;
[b]end[/b];
[b]end[/b].
Code:
[navy][i]{---- NuSvc unit ----}[/i][/navy]
[b]unit[/b] NuSvc;
[b]interface[/b]
[b]uses[/b]
SvcMgr;
[b]type[/b]
TNuService = [b]class[/b](TService)
[b]end[/b];
[b]implementation[/b]
[b]end[/b].
produces the error. All I did was create a new service application, add the NuSvc reference, and change TService to TNuService. Compiles fine. Close, won't reload correctly.
Using Delphi 6. Everything looks as though it should work. It makes no sense that this shouldn't work, because all I'm doing is inserting my service class between TService1 and TService anyway.
Maybe I just need some fresh eyes and brains. Anyone got any clues?