473,769 Members | 5,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can anyone tell me why Invoking from a service doesn't work please? - Service Problem.txt (0/1)

Hi All,

I am using a COM object and so I have to use a form for it to work.
The problem is I need to run it as a service as well.
When I run it in a test scenario everything works fine and Invoke
works as expected.
However, when I run it as a service the Invoke command just bombs out
without any errors and everything just stops. I have the service
installed using an administrator account and interacting with the
desktop for testing.

The code I use is below. 'Test' is the form with the COM object on it.
This is my test code and everything works as expected if I set
RunAsService to False and run it from the IDE.
If I compile and install as a service and set RunAsService to TRUE,
Start the service from the MMC and then
attach to it. When I get to the Me.Invoke(SP) line it just hangs until
I terminate the process. No errors or anything.
Can anyone tell me why this might be please.

Many thanks,

Mike
Imports System.ServiceP rocess
Imports System
Imports System.Diagnost ics
Imports System.Componen tModel

Public Class svcTest
Inherits System.ServiceP rocess.ServiceB ase
Private Delegate Sub InitDelegate(By Val args() As String)
Private Test As New Test

#Region " Component Designer generated code "

Public Sub New()
MyBase.New()

' This call is required by the Component Designer.
InitializeCompo nent()

' Add any initialization after the InitializeCompo nent() call

End Sub

'UserService overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As
Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

' The main entry point for the process
<MTAThread()> _
Shared Sub Main()
Dim RunAsService As Boolean = False

If RunAsService Then
Dim ServicesToRun() As System.ServiceP rocess.ServiceB ase
ServicesToRun = New System.ServiceP rocess.ServiceB ase()
{New svcTest}
System.ServiceP rocess.ServiceB ase.Run(Service sToRun)
Else
Dim DebugService As New svcTest
Dim InitDelegate As InitDelegate = New
InitDelegate(Ad dressOf DebugService.On Start)
InitDelegate.Be ginInvoke(Nothi ng, Nothing, Nothing)
System.Windows. Forms.Applicati on.Run()
End If

End Sub

'Required by the Component Designer
Private components As System.Componen tModel.IContain er

' NOTE: The following procedure is required by the Component
Designer
' It can be modified using the Component Designer.
' Do not modify it using the code editor.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
'
'OmegaIPVAD
'
Me.ServiceName = "OmegaIPVAD "

End Sub

#End Region

Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set
things
' in motion so your service can do its work.
Go()
End Sub

Protected Overrides Sub OnStop()

End Sub

Sub Go()
Test.Init()
End Sub
End Class
Imports System.Threadin g

Public Class Test
Inherits System.Windows. Forms.Form

#Region "Variables"

Private Delegate Sub InvokeDelegateN oParams()

#End Region

Public Sub New()
'Even though this is a windowless form we still need to show
the form
'so that the message loop starts.
MyBase.New()
Me.Show()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

End Sub

Private Sub InitializeCompo nent()

Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(168, 144)
Me.Name = "Test"
Me.ShowInTaskba r = False
End Sub

Public Sub Init()
If Me.InvokeRequir ed = True Then
Dim SP As InvokeDelegateN oParams = New
InvokeDelegateN oParams(Address Of Init)
Try
Me.Invoke(SP)
Exit Sub
Catch ex As Exception
End Try
End If

DoStuff()
End Sub
End Class
Nov 20 '05 #1
0 1216

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1521
by: reynArd | last post by:
"I can teach anyone how to get what they want out of life. The problem is I can't find anybody who can tell me what they want." -- Mark Twain "Today people in America can become whatever they want. Trouble is most don't know what they want." -- Earl Nightingale What do you want? Are you sick of the rat race? Are you tired of having someone else tell you what they think you're worth? Would you rather work from home, set you own hours, and pay...
6
6181
by: Patrick | last post by:
Following earlier discussions about invoking a .NET class library via ..NET-COM Interop (using regasm /tlb) at http://groups.google.com/groups?hl=en&lr=&threadm=%23Van7eSrEHA.4004%40TK2MSFTNGP10.phx.gbl&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26selm%3D%2523Van7eSrEHA.4004%2540TK2MSFTNGP10.phx.gbl I have concluded that my .NET class library (following the suggestions. namely setting the marshall type, etc.) , I can 1) Invoke public methods...
13
7779
by: Patrick | last post by:
I understand that with IIS5.1 on Windows XP Professional SP1, I can 1) Either set under IIS Manager-> Any specific Virtual Directory-> Configuration->Options->ASP Script timeout for all pages within that directory OR 2) Within a specific page, set the timeout as per http://www.microsoft.com/windows2000/en/server/iis/default.asp?url=/windows2000/en/server/iis/htm/asp/vbob246s.htm e.g. <% Server.ScriptTimeout = 1 %> and that the value in...
0
1350
by: reynArd | last post by:
"I can teach anyone how to get what they want out of life. The problem is I can't find anybody who can tell me what they want." -- Mark Twain "Today people in America can become whatever they want. Trouble is most don't know what they want." -- Earl Nightingale What do you want? Are you sick of the rat race? Are you tired of having someone else tell you what they think you're worth? Would you rather work from home, set you own hours, and pay...
11
5565
by: ricolee99 | last post by:
Hi everyone, I'm trying to invoke my .exe application from a remote server. Here is the code: ManagementClass processClass = new ManagementClass ("\\\\" +"RemoteServerName" + "\\root\\CIMV2:Win32_Process");
5
2937
by: Stu Carter | last post by:
Hi, ENV: Windows 2003 Server SP1 (+all updates), VS 2003, .Net 1.1 SP1 We've got an ASP.Net web application using State Service. All is fine until we tried to use the app through a virtual directory with a space in it. e.g. 'http://localhost/My%20App'. The following exception is thrown: ----------
7
2095
by: Giulio Petrucci | last post by:
Hi everybody, I've a big problem with a Windows Service I've created using C#. It's a very simple service: it just starts a TcpListener listening for incoming connections on a certain ports. First I compiled it on FW2.0, and run the service without any problem. Some days ago I had to performe a sort of "backporting" to FW1.1, I compiled the source code, installed the service but as I try to start it I get a timeout and a system error. I...
1
1560
by: Ronald S. Cook | last post by:
Performance in our WCF application is very poor now that we've added a number of records to tables (not an unrealistic number, though). After doing that, we did get "max message size" errors to I bumped that number to 99999999 (see below). Can anyone please tell me if (1) my config files below look ok, and (2) you have any other ideas why things might be so slow? Thanks VERY much for any feedback, Ron
0
9586
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10043
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.