469,582 Members | 2,525 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,582 developers. It's quick & easy.

A Service in VB.NET 2005 using a form ?

Hi,

I have created a Service with vb.NET 2005 and I want to show a form. How can
I do this? Can I do it like this? Or should'nt I use a form in a service at
all?

Private oMain As Main

Protected Overrides Sub OnStart(ByVal args() As String)
' Code zum Starten des Dienstes hier einfügen. Diese Methode sollte
Vorgänge
' ausführen, damit der Dienst gestartet werden kann.

Try
oMain = New Main
oMain.Show()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub

If I do so then the form is shown but it say "No response".

Thanks in advance

Kind regards

Stefan

Aug 30 '06 #1
4 1272
Hi
>From what I understand you shouldn't have any UI elements in your
service as a service can run irrespective of whether a user is logged
on or not and runs under a system process etc. (could be wrong though).
If you just want the user to be able to interact with your service
(changing settings, start/stop the service etc) then take a look at the
following article that should help.

http://www.devcity.net/Articles/74/1...ontroller.aspx
Thanks
Martin
hex40 wrote:
Hi,

I have created a Service with vb.NET 2005 and I want to show a form. How can
I do this? Can I do it like this? Or should'nt I use a form in a service at
all?

Private oMain As Main

Protected Overrides Sub OnStart(ByVal args() As String)
' Code zum Starten des Dienstes hier einfgen. Diese Methode sollte
Vorgnge
' ausfhren, damit der Dienst gestartet werden kann.

Try
oMain = New Main
oMain.Show()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub

If I do so then the form is shown but it say "No response".

Thanks in advance

Kind regards

Stefan
Aug 30 '06 #2
IN VB6 I wrote an exe having several forms. You could run this Program as a
service If you used a ntsvc.ocx. In the property page of the service you had
to say that the service runs under the local system account and that it
interacts with the desktop.
My Service in VB.NET logs on an ftp Server and processes documents. And I
want to show the ftp communication in a form and also what the actual batch
is that is uploaded etc. If I have to write a service without UI then I
should write another program that interacts with my service. How can I manage
this? .NET Remoting? I can't find a simple exmaple for that technique!

Thanks in advance

Stefan

"Pritcham" schrieb:
Hi
From what I understand you shouldn't have any UI elements in your
service as a service can run irrespective of whether a user is logged
on or not and runs under a system process etc. (could be wrong though).
If you just want the user to be able to interact with your service
(changing settings, start/stop the service etc) then take a look at the
following article that should help.

http://www.devcity.net/Articles/74/1...ontroller.aspx
Thanks
Martin
hex40 wrote:
Hi,

I have created a Service with vb.NET 2005 and I want to show a form. How can
I do this? Can I do it like this? Or should'nt I use a form in a service at
all?

Private oMain As Main

Protected Overrides Sub OnStart(ByVal args() As String)
' Code zum Starten des Dienstes hier einfügen. Diese Methode sollte
Vorgänge
' ausführen, damit der Dienst gestartet werden kann.

Try
oMain = New Main
oMain.Show()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub

If I do so then the form is shown but it say "No response".

Thanks in advance

Kind regards

Stefan

Aug 30 '06 #3
Hi
>From what I understand you can mark a service as interacting with the
desktop from the Services control panel - not sure how you would do
this via code.

As for how you could/would have another program to interact with your
service, this is detailed in the link I suggested (which uses IIS as
its example service).

Again, I'm not overly familiar with service programming so all of this
is info I've gleaned recently while looking at whether creating a
service was the right thing for me (which it wasn't in the end) but if
you need to interact with your service then you can issue custom
commands to your service for it to perform whatever actions you need it
to.

Sorry I can't be of more help

Martin

hex40 wrote:
IN VB6 I wrote an exe having several forms. You could run this Program asa
service If you used a ntsvc.ocx. In the property page of the service you had
to say that the service runs under the local system account and that it
interacts with the desktop.
My Service in VB.NET logs on an ftp Server and processes documents. And I
want to show the ftp communication in a form and also what the actual batch
is that is uploaded etc. If I have to write a service without UI then I
should write another program that interacts with my service. How can I manage
this? .NET Remoting? I can't find a simple exmaple for that technique!

Thanks in advance

Stefan

"Pritcham" schrieb:
Hi
>From what I understand you shouldn't have any UI elements in your
service as a service can run irrespective of whether a user is logged
on or not and runs under a system process etc. (could be wrong though).
If you just want the user to be able to interact with your service
(changing settings, start/stop the service etc) then take a look at the
following article that should help.

http://www.devcity.net/Articles/74/1...ontroller.aspx
Thanks
Martin
hex40 wrote:
Hi,
>
I have created a Service with vb.NET 2005 and I want to show a form. How can
I do this? Can I do it like this? Or should'nt I use a form in a service at
all?
>
Private oMain As Main
>
Protected Overrides Sub OnStart(ByVal args() As String)
' Code zum Starten des Dienstes hier einfgen. Diese Methode sollte
Vorgnge
' ausfhren, damit der Dienst gestartet werden kann.
>
Try
oMain = New Main
oMain.Show()
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
>
If I do so then the form is shown but it say "No response".
>
Thanks in advance

Kind regards

Stefan
Aug 30 '06 #4
hex40 wrote:
IN VB6 I wrote an exe having several forms. You could run this Program as a
service If you used a ntsvc.ocx. In the property page of the service you had
to say that the service runs under the local system account and that it
interacts with the desktop.
You can do the same with a service created in VB.Net. But it is not
recommended. I also read that in Windows Vista, coming out Q1 next
year, that services will no longer be able to interact with the
desktop. If you will be upgrading to Vista any time soon, you might
have troubles with your service. I'm not 100% sure on this last
point, however.
My Service in VB.NET logs on an ftp Server and processes documents. And I
want to show the ftp communication in a form and also what the actual batch
is that is uploaded etc. If I have to write a service without UI then I
should write another program that interacts with my service. How can I manage
this? .NET Remoting? I can't find a simple exmaple for that technique!
I believe that is the recommended approach. You might also be able to
use named pipes to have your UI program communicate with your service.
I don't have an example handy, but you should be able to Google one up,
though.

Aug 30 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Szafranr | last post: by
10 posts views Thread by Bryan Dickerson | last post: by
4 posts views Thread by tshad | last post: by
9 posts views Thread by jsoques | last post: by
10 posts views Thread by Ben | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.