-
vb app as nt service with dcom
How do I get DCOM to work with my VB app that runs as an NT Service? My app
runs fine as an NT Service. It mostly just collects information. But I want
to use DCOM to expose a routine that will provide some of that information
to remote clients.
I am using the NTSVC.OCX to provide the NT Service part.
When I tried using my app as an OutOfProcessServer(ActiveX.exe), each time
the client made a request, it loaded a new instance of my app, rather than
just invoking my exposed routine.
Is this possible?
Should it be designed as a standard exe instead?
Any help would be appreciated, including samples.
-
Re: vb app as nt service with dcom
Mike,
> How do I get DCOM to work with my VB app that runs as an NT Service? My
app
> runs fine as an NT Service. It mostly just collects information. But I
want
> to use DCOM to expose a routine that will provide some of that information
> to remote clients.
>
> I am using the NTSVC.OCX to provide the NT Service part.
Sorry, but I've failed to get VB services to expose their OLEness as
services. Perhaps someone else has had better luck. The choices I know work
now are: C++ and Appleman's Services toolkit for VB.
--
L.J. Johnson, Slightly Tilted Software
Microsoft MVP (Visual Basic)
LJJohnsn@Flash.Net or LJJohnson@mvps.org
<http://www.flash.net/~ljjohnsn>
Ask The NT Pro at <http://www.inquiry.com>
-
Re: vb app as nt service with dcom
"Mike" <mhusek@klink.net> wrote:
>
>How do I get DCOM to work with my VB app that runs as an NT Service? My
app
>runs fine as an NT Service. It mostly just collects information. But I want
>to use DCOM to expose a routine that will provide some of that information
>to remote clients.
>
>I am using the NTSVC.OCX to provide the NT Service part.
>
>When I tried using my app as an OutOfProcessServer(ActiveX.exe), each time
>the client made a request, it loaded a new instance of my app, rather than
>just invoking my exposed routine.
If I understand you correctly, you'd like to have reference on the same instance
of ActiveX EXE, without cration a new one with each client . Why do not try
to do this with GetObject function?
It has format:Set objectvariable=GetObject([pathname] [, progID])
if to ommit pathname, you'll get reference on existing instance of EXE rather
then creating a new one.
Set X = GetObject(, "MySrvr.Application")
X references an existing Application object (MSDN)
Sorry if I missunderstood you.
>
>Is this possible?
>Should it be designed as a standard exe instead?
>Any help would be appreciated, including samples.
-
Re: vb app as nt service with dcom
"Oleg" <okostenko@hotmail.com> wrote:
>
>"Mike" <mhusek@klink.net> wrote:
>>
>>How do I get DCOM to work with my VB app that runs as an NT Service? My
>app
>>runs fine as an NT Service. It mostly just collects information. But I
want
>>to use DCOM to expose a routine that will provide some of that information
>>to remote clients.
>>
>>I am using the NTSVC.OCX to provide the NT Service part.
>>
>>When I tried using my app as an OutOfProcessServer(ActiveX.exe), each time
>>the client made a request, it loaded a new instance of my app, rather than
>>just invoking my exposed routine.
>
>If I understand you correctly, you'd like to have reference on the same
instance
>of ActiveX EXE, without cration a new one with each client . Why do not
try
>to do this with GetObject function?
>It has format:Set objectvariable=GetObject([pathname] [, progID])
>if to ommit pathname, you'll get reference on existing instance of EXE rather
>then creating a new one.
>Set X = GetObject(, "MySrvr.Application")
> X references an existing Application object (MSDN)
>Sorry if I missunderstood you.
>
>>
>>Is this possible?
>>Should it be designed as a standard exe instead?
>>Any help would be appreciated, including samples.
>
Then how do I specify the Server that I want to use?
CreateObject allows me to specify the Server name.
-
Re: vb app as nt service with dcom
"Mike" <mhusek@klinknet.net> wrote:
>
>"Oleg" <okostenko@hotmail.com> wrote:
>>
>>"Mike" <mhusek@klink.net> wrote:
>>>
>>>How do I get DCOM to work with my VB app that runs as an NT Service? My
>>app
>>>runs fine as an NT Service. It mostly just collects information. But I
>want
>>>to use DCOM to expose a routine that will provide some of that information
>>>to remote clients.
>>>
>>>I am using the NTSVC.OCX to provide the NT Service part.
>>>
>>>When I tried using my app as an OutOfProcessServer(ActiveX.exe), each
time
>>>the client made a request, it loaded a new instance of my app, rather
than
>>>just invoking my exposed routine.
>>
>>If I understand you correctly, you'd like to have reference on the same
>instance
>>of ActiveX EXE, without cration a new one with each client . Why do not
>try
>>to do this with GetObject function?
>>It has format:Set objectvariable=GetObject([pathname] [, progID])
>>if to ommit pathname, you'll get reference on existing instance of EXE
rather
>>then creating a new one.
>>Set X = GetObject(, "MySrvr.Application")
>> X references an existing Application object (MSDN)
>>Sorry if I missunderstood you.
>>
>>>
>>>Is this possible?
>>>Should it be designed as a standard exe instead?
>>>Any help would be appreciated, including samples.
>>
>
>Then how do I specify the Server that I want to use?
>CreateObject allows me to specify the Server name.
>
>
Let me explain my problem in more detail:
(1) I have a VB app that runs as an NT Service on several server machines.
(2) It uses the NTSVC.OCX for the NT Service part and it works OK.
(3) Its main purpose is to constantly collect some info about the server
that it is running on.
(4) The info that it collects is stored in a global variable in the server
app.
(5) I have a client app that needs to get that information from a particular
server.(Not just any of these servers).
(6) I would like to use DCOM in my Server app to expose a routine(GetInfo)
that would return the info that it has collected in the global variable,
making it available to my client app.
(7) The NTSVC.OCX requires that my ActiveX.EXE have a startup object (form
or sub) so that it can respond to commandline commands such as "serverexename
-install" or "serverexename -uninstall" and service requests such as "NET
START servicename" and "NET STOP servicename".
(8) The problem that I am having is that whenever my client app tries to
use the DCOM routine(GetInfo) to get the info in the servers global variable,
DCOM drives the servers startup object (form or sub), instead of just the
DCOM exposed routine(GetInfo).
(9) There must be only one instance of my server app running on each server
machine so that the current contents of the global variable is returned to
the client app.
How can I prevent the startup object from getting called?
How can I prevent another instance of the server app from being created?
What is the proper way for my client app to call the GetInfo DCOM routine?
All/any help would be greatly appreciated.
-
Re: vb app as nt service with dcom
"Mike" <mhusek@klink.net> wrote:
>
>"Mike" <mhusek@klinknet.net> wrote:
>>
>>"Oleg" <okostenko@hotmail.com> wrote:
>>>
>>>"Mike" <mhusek@klink.net> wrote:
>>>>
>>>>How do I get DCOM to work with my VB app that runs as an NT Service?
My
>>>app
>>>>runs fine as an NT Service. It mostly just collects information. But
I
>>want
>>>>to use DCOM to expose a routine that will provide some of that information
>>>>to remote clients.
>>>>
>>>>I am using the NTSVC.OCX to provide the NT Service part.
>>>>
>>>>When I tried using my app as an OutOfProcessServer(ActiveX.exe), each
>time
>>>>the client made a request, it loaded a new instance of my app, rather
>than
>>>>just invoking my exposed routine.
>>>
>>>If I understand you correctly, you'd like to have reference on the same
>>instance
>>>of ActiveX EXE, without cration a new one with each client . Why do not
>>try
>>>to do this with GetObject function?
>>>It has format:Set objectvariable=GetObject([pathname] [, progID])
>>>if to ommit pathname, you'll get reference on existing instance of EXE
>rather
>>>then creating a new one.
>>>Set X = GetObject(, "MySrvr.Application")
>>> X references an existing Application object (MSDN)
>>>Sorry if I missunderstood you.
>>>
>>>>
>>>>Is this possible?
>>>>Should it be designed as a standard exe instead?
>>>>Any help would be appreciated, including samples.
>>>
>>
>>Then how do I specify the Server that I want to use?
>>CreateObject allows me to specify the Server name.
>>
>>
>Let me explain my problem in more detail:
>
> (1) I have a VB app that runs as an NT Service on several server machines.
> (2) It uses the NTSVC.OCX for the NT Service part and it works OK.
> (3) Its main purpose is to constantly collect some info about the server
>that it is running on.
> (4) The info that it collects is stored in a global variable in the server
>app.
> (5) I have a client app that needs to get that information from a particular
>server.(Not just any of these servers).
> (6) I would like to use DCOM in my Server app to expose a routine(GetInfo)
>that would return the info that it has collected in the global variable,
>making it available to my client app.
> (7) The NTSVC.OCX requires that my ActiveX.EXE have a startup object (form
>or sub) so that it can respond to commandline commands such as "serverexename
>-install" or "serverexename -uninstall" and service requests such as "NET
>START servicename" and "NET STOP servicename".
> (8) The problem that I am having is that whenever my client app tries to
>use the DCOM routine(GetInfo) to get the info in the servers global variable,
>DCOM drives the servers startup object (form or sub), instead of just the
>DCOM exposed routine(GetInfo).
> (9) There must be only one instance of my server app running on each server
>machine so that the current contents of the global variable is returned
to
>the client app.
>
>How can I prevent the startup object from getting called?
>
>How can I prevent another instance of the server app from being created?
>
>What is the proper way for my client app to call the GetInfo DCOM routine?
>
>All/any help would be greatly appreciated.
>
>
I see one way- to deploy on each server another ActiveX object(A),which will
be instanciated on server with aech client request with CreateObject, but
each of A object instances can get a refrence on a single instance of your
server app with GetObject(,"serverapp"). This will prevent instanciation
of serverapp with each request. After this A can return your global variable
(returned by single server app instance) to client.
-
Re: vb app as nt service with dcom
"Mike" <mhusek@klink.net> wrote in message news:39071acd$1@news.devx.com...
>
> How can I prevent the startup object from getting called?
I don't think there is any "startup object" here - this is simply
initialisation code. You can't prevent it from being called. However, you
<could> use:
Sub Main()
Select Case App.StartMode
Case vbSModeAutomation
' User has created an instance via COM/DCOM
Case vbSModeStandalone
' User has started app via command line
End If
End Sub
Look on the help on StartMode to see what it does.
>
> How can I prevent another instance of the server app from being created?
I <would> have said use App.PrevInstance, however, the following note is
made in the documentation;
<QUOTE>
Remarks
You can use this property in a Load event procedure to specify whether a
user is already running an instance of an application. Depending on the
application, you might want only one instance running in the Microsoft
Windows operating environment at a time.
Note Since a computer running Windows NT can support multiple desktops, if
you use a component designed to work with distributed COM, it can result in
the following scenario:
A client program in a user desktop requests one of the objects the component
provides. Because the component is physically located on the same machine,
the component is started in the user desktop.
Subsequently, a client program on another computer uses distributed COM to
request one of the objects the component provides. A second instance of the
component is started, in a system desktop.
There are now two instances of the component running on the same NT
computer, in different desktops.
This scenario is not a problem unless the author of the component has placed
a test for App.PrevInstance in the startup code for the component to prevent
multiple copies of the component from running on the same computer. In this
case, the remote component creation will fail.
</QUOTE>
I imagine the same would apply if you tested using the API mechanism ...
which ... I can't quite remember, except to say I saw it on some website.
>
> What is the proper way for my client app to call the GetInfo DCOM routine?
Create an instance of your accessor class, and then call GetInfo, I suppose
(you can't use the "automatic instantiation" ability GlobalMultiUse classes
with CreateObject.
--
---------------------------------------
Mark Alexander Bertenshaw
Programmer/Analyst
Prime Response
Brentford
UK
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|