🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.csharpbuilder.language.csharp
Article #679

Re: writng Win32service in BorlandC#Builder How do I do it?

#679
From: Marc Rohloff TeamB
Date: Mon, 25 Oct 2004 10:54
47 lines
3108 bytes
On Mon, 25 Oct 2004 09:19:06 +0200, J.A Smit wrote:

> When I build this get an error at "public class JurService :
> System.ServiceProcess.ServiceBase" it says  :"Expected
> class,delegate,enum,interface or struct".
> It seems like the class isn't recognised.
> Maybe important to know, I created the project as a C#  Appllication. I
> stripped everything from the main source file and inserted the code found
> above.

The code above doesn't have a JurService class so I assume you didn't
post your real code. 
Did you add a reference to the System.ServicePorcess assembly?
I suggest you put your class into a namespace.

> I also found some stuff on ProcessInstaller and ServiceprocessInstaller do I
> put it in the same sourcefile?(I think not).
IIRC, some of theses are attributes so they should go in the same
source file. Otherwise they just have to be in the same assembly.
(There is an installer which comes with .net that will read your
assembly)



> The main problem I have is:
> How do I build the project, file wise. As far as I can see now, you need:
> A sourcefile with the subclass of ServiceBase and a handler for the OnRun
> method.
> A sourcefile witch controls installation of the service (do I also need the
> ServiceProcessInstaller class when I install only one service?
As I said you only have one assembly (which may contain more than one
source file). The .net installer will read this file and find the
ServiceProcessInstaller class and use it to register the service. This
is true even if you only have one service. (Unless you want to
register it manually, which you don't)

> I don't know what you mean by "you will need to spawn a thread........" what
> is ment with "thread" in this context?
The OnStart, OnStop, etc methods need to return almost immediately so
you cannot put your main process in there since it will run almost
continuously. You will generally need to start a separate execution
thread and run it from there. (There are other ways but this is the
most common)

-- 
Marc Rohloff [TeamB]
marc rohloff at myrealbox dot com
Technical Details
Message-ID: <l20k7t6gap29.dlg@marcrohloff.40tude.net>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!newsprint.newsread.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <417bf043$1@newsgroups.borland.com> <hyra00h6xyiu$.dlg@marcrohloff.40tude.net> <417ca911$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,a97d3f9f5adb9274
X-Google-Attributes: gid1efe35,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Marc Rohloff [TeamB]" <"on request">
Subject: Re: writng Win32service in BorlandC#Builder How do I do it?
Newsgroups: borland.public.csharpbuilder.language.csharp
User-Agent: 40tude_Dialog/2.0.14.1
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
References: <417bf043$1@newsgroups.borland.com> <hyra00h6xyiu$.dlg@marcrohloff.40tude.net> <417ca911$1@newsgroups.borland.com>
Date: Mon, 25 Oct 2004 06:54:48 -0400
Message-ID: <l20k7t6gap29.dlg@marcrohloff.40tude.net>
NNTP-Posting-Host: 4.131.32.212
X-Trace: newsgroups.borland.com 1098701719 4.131.32.212 (25 Oct 2004 03:55:19 -0700)
Lines: 47
X-Authenticated-User: mrohloff
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!newsprint.newsread.com!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail