Board index » delphi » Instancing COM objects from an NT service

Instancing COM objects from an NT service

I have an NT service, which has its own Automation object, which I
instantiate etc. This works fine.
But when this object in question tries to instantiate a different COM object
located in a separate DLL,
the CreateComObject call hangs. I have no problem instantiating the object
in question from a normal App,
and I have no problem instantiating the internal Automation object, so
whats.
Basically, the problem seems to have to do with the com object being in a
DLL outside of my EXE.

/Bjorn

 

Re:Instancing COM objects from an NT service


Hi,

I haven't been much help to your postings in the past, and maybe this time will
be no different, but I'll try. :)

Have you looked into the permissions of the service? I would look into the 'Run
as Interactive User' checkbox that you can opt for when running as a System
process (from Control Panel/Services), as well as setting the service to log in
via a user account. I am guessing that if you set the service to log in as a
user, you will be able to instantiate the COM object.

This won't solve your problem, but it might give you a start. Good luck.

Best regards,

Steve Midgley

Quote
Bj?rn Lindell wrote:
> I have an NT service, which has its own Automation object, which I
> instantiate etc. This works fine.
> But when this object in question tries to instantiate a different COM object
> located in a separate DLL,
> the CreateComObject call hangs. I have no problem instantiating the object
> in question from a normal App,
> and I have no problem instantiating the internal Automation object, so
> whats.
> Basically, the problem seems to have to do with the com object being in a
> DLL outside of my EXE.

> /Bjorn

Re:Instancing COM objects from an NT service


Neither "Run As Interactive User" or setting a specific user account
works...
I still have no clue how to do it (instanciating COM object that is not
within the service-exe itself, but in a separate DLL (in-process server)
)

Quote
Steve Midgley wrote in message <35045E69.1C5EC01E@abomb_anti-spam.com>...
>Hi,

>I haven't been much help to your postings in the past, and maybe this time
will
>be no different, but I'll try. :)

>Have you looked into the permissions of the service? I would look into the
'Run
>as Interactive User' checkbox that you can opt for when running as a System
>process (from Control Panel/Services), as well as setting the service to
log in
>via a user account. I am guessing that if you set the service to log in as
a
>user, you will be able to instantiate the COM object.

>This won't solve your problem, but it might give you a start. Good luck.

>Best regards,

>Steve Midgley

>Bj?rn Lindell wrote:

>> I have an NT service, which has its own Automation object, which I
>> instantiate etc. This works fine.
>> But when this object in question tries to instantiate a different COM
object
>> located in a separate DLL,
>> the CreateComObject call hangs. I have no problem instantiating the
object
>> in question from a normal App,
>> and I have no problem instantiating the internal Automation object, so
>> whats.
>> Basically, the problem seems to have to do with the com object being in a
>> DLL outside of my EXE.

>> /Bjorn

Re:Instancing COM objects from an NT service


Did you try login in your app as a user and impersonating him ? The probleme
may be that your objects needs some security descriptor your service doesn't
have so, impersonati^ng a user with sufficient rights to instanciate the
user directly may do the trick.

Stephane
----
Stephane Grobety,
Corporate:
 GIT S.A.
 EMail: Stephane.grob...@git.ch  WWW: http://www.git.ch/
private:
 EMail: Grob...@fulgan.com  WWW: http://www.fulgan.com/
-----
"The world is flat, if you see a globe, it only a rendering effect"

Quote
Bjorn Lindell wrote in message <6e3eov$7...@forums.borland.com>...
>Neither "Run As Interactive User" or setting a specific user account
>works...
>I still have no clue how to do it (instanciating COM object that is not
>within the service-exe itself, but in a separate DLL (in-process server)
>)

>Steve Midgley wrote in message <35045E69.1C5EC01E@abomb_anti-spam.com>...
>>Hi,

>>I haven't been much help to your postings in the past, and maybe this time
>will
>>be no different, but I'll try. :)

>>Have you looked into the permissions of the service? I would look into the
>'Run
>>as Interactive User' checkbox that you can opt for when running as a
System
>>process (from Control Panel/Services), as well as setting the service to
>log in
>>via a user account. I am guessing that if you set the service to log in as
>a
>>user, you will be able to instantiate the COM object.

>>This won't solve your problem, but it might give you a start. Good luck.

>>Best regards,

>>Steve Midgley

>>Bj?rn Lindell wrote:

>>> I have an NT service, which has its own Automation object, which I
>>> instantiate etc. This works fine.
>>> But when this object in question tries to instantiate a different COM
>object
>>> located in a separate DLL,
>>> the CreateComObject call hangs. I have no problem instantiating the
>object
>>> in question from a normal App,
>>> and I have no problem instantiating the internal Automation object, so
>>> whats.
>>> Basically, the problem seems to have to do with the com object being in
a
>>> DLL outside of my EXE.

>>> /Bjorn

Re:Instancing COM objects from an NT service


I solved the problem. I needed to declare the objects in the registry with
ThreadingModel=Apartment
then they could easily be instantiated.

Does anyone know why this threadingmodel declaration was needed, why
it hangs on CreateComObject if not and only from within a service?

Other Threads