Board index » delphi » Dcom server in an NT service

Dcom server in an NT service

Could some one please share their experience on this
in a large project.( with more than 2 RDMs and Shared
Connections and Dlls )
Thanks
-VJ

 

Re:Dcom server in an NT service


Vijayan,

Quote
> Could some one please share their experience on this
> in a large project.( with more than 2 RDMs and Shared
> Connections and Dlls )

Do you have some more specific questions about the subject?

I am employed working on a project - server, corporate software - that
includes a NT/2000 service using a MTS/COM+ component... that *nearly*
complies ;-)  I'd be glad to help if I can.

Cheers,
Thomas

Re:Dcom server in an NT service


Thomas,First of all thank you ! Here is  my scenario.

I converted our dcom server ( consisting of one or more remote
datamodules with shared connection ) to an NT service by using Delphi TServiceApplication
frame work.Service unit just contains the usual code that delphi
generated.

procedure ServiceController(CtrlCode: DWord); stdcall;
begin
  ServiceProcess.Controller(CtrlCode);
end;

function TServiceProcess.GetServiceController: TServiceController;
begin
  Result := ServiceController;
end;

procedure TServiceProcess.ServiceExecute(Sender: TService);
begin
   while not Terminated do
   begin
        ServiceThread.ProcessRequests(False);
        Sleep(500);
   end;
end;

And I have registerasService code in  my main data module only(below).

class procedure TMainRDM.UpdateRegistry(Register: Boolean; const ClassID, ProgID: string);
begin
  if Register then
  begin
        inherited UpdateRegistry(Register, ClassID, ProgID);
        RegisterAsService(ClassID,'ServiceName');
        EnableSocketTransport(ClassID);
        EnableWebTransport(ClassID);
  end else
  begin
        DisableSocketTransport(ClassID);
        DisableWebTransport(ClassID);
        inherited UpdateRegistry(Register, ClassID, ProgID);
  end;
end;

1.Everything works ok.Just wondering it this is all I need to do or is anthing further one has to do  when it comes to com object inside a service.Please advise.

2.Service starts automatically when any one accesses the com  server.Eventhough I can live with that , just wondering why that happens.Is there way can I prevent that ? Look like my
com object is not really inside the service.

3.Thirdly I can stop the service without any problem and the connected client get an rpc server unavailable message.
Is there any way can I find out if there are active connections and give a warning and then try to ditch the clients and stop the service.

-VJ

Re:Dcom server in an NT service


Quote
"Vijayan Pillai" <pillai_vija...@hotmail.com> wrote in message

news:3bb8ee39$1_2@dnews...

First warning, the VCL service library is not explicitly compatible with the
VCL COM library. For more details, check out Alexey Dynnikov's pages.

Quote
> 1.Everything works ok.Just wondering it this is all I need to do or is

anthing further one has to do  when it comes to com object inside a
service.Please advise.
Quote

> 2.Service starts automatically when any one accesses the com

server.Eventhough I can live with that , just wondering why that happens.Is
there way can I prevent that ? Look like my

Quote
> com object is not really inside the service.

This is probably because the LocalService registry key is incorrect. When
you call RegisterAsService, make sure the GUID you pass in is the actual
AppID that your application uses. To obtain the real AppID, you'll have to
study and infer how DCOMCNFG picks an AppID for you.

Quote
> 3.Thirdly I can stop the service without any problem and the connected

client get an rpc server unavailable message.
Quote
> Is there any way can I find out if there are active connections and give a

warning and then try to ditch the clients and stop the service.

ComServer.ObjectCount might help.

--
have fun
Binh Ly
http://www.techvanguards.com

Re:Dcom server in an NT service


Binh,
Thank you very much !
One question(below)

Quote
>This is probably because the LocalService registry key is incorrect. When
>you call RegisterAsService, make sure the GUID you pass in is the actual
>AppID that your application uses. To obtain the real AppID, you'll have to
>study and infer how DCOMCNFG picks an AppID for you.

How do I do this ?
-VJ

Re:Dcom server in an NT service


Run DCOMCNFG and search for the AppID it assigns to your COM server (In the
registry, HKCR\AppID). From past experience, I've found that DCOMCNFG picks
the lowest valued CLSID and makes that your AppID. However, this is not
documented and may not work for you.

--
have fun
Binh Ly
http://www.techvanguards.com

Quote
"Vijayan Pillai" <pillai_vija...@hotmail.com> wrote in message

news:3bb92086$1_2@dnews...
Quote

> Binh,
> Thank you very much !
> One question(below)

> >This is probably because the LocalService registry key is incorrect. When
> >you call RegisterAsService, make sure the GUID you pass in is the actual
> >AppID that your application uses. To obtain the real AppID, you'll have
to
> >study and infer how DCOMCNFG picks an AppID for you.

> How do I do this ?
> -VJ

Re:Dcom server in an NT service


Binh,

Quote
>Run DCOMCNFG and search for the AppID it assigns to your COM server (In the
>registry, HKCR\AppID). From past experience, I've found that DCOMCNFG picks
>the lowest valued CLSID and makes that your AppID. However, this is not
>documented and may not work for you.

Thank you very much !

That didn't work for me.Since you said service and com library are not compatible what steps should I do to prevent the clients from accessing the server when the service is stopped and connects only when the service is running.
-VJ

Other Threads