PC Review


Reply
Thread Tools Rate Thread

Self installing services

 
 
=?Utf-8?B?QnVyZ2E=?=
Guest
Posts: n/a
 
      24th Nov 2004
I have a simple service written in VB.net that can be installed and removed
successfully using srvinst. I'd like to make this file self installing though
(for example, run from the command line with an argument to get it
instantiated in the SCM). I've done this in the past by calling createprocess
WinAPI directly... but I'm guessing there must be a way to do this better in
VB.Net. I began looking at calling the Install method on ServiceInstaller and
ServiceProcessInstaller, but anything I try fails with a crash. From what I
can tell, MS does not expect you to write to these methods as they are to be
called by install programs. Usage and examples are hard to find.

Does anybody know how to call the ServiceInstall and ServiceProcessInstall
methods to install the service successfully?
 
Reply With Quote
 
 
 
 
Hayato Iriumi
Guest
Posts: n/a
 
      25th Nov 2004
Hello Burga,

If you are trying to install Windows Service created by VB .NET, can't you use InstallUtil to install it? What exactly do you need to accomplish on installation?

> I have a simple service written in VB.net that can be installed and
> removed successfully using srvinst. I'd like to make this file self
> installing though (for example, run from the command line with an
> argument to get it instantiated in the SCM). I've done this in the
> past by calling createprocess WinAPI directly... but I'm guessing
> there must be a way to do this better in VB.Net. I began looking at
> calling the Install method on ServiceInstaller and
> ServiceProcessInstaller, but anything I try fails with a crash. From
> what I can tell, MS does not expect you to write to these methods as
> they are to be called by install programs. Usage and examples are
> hard to find.
>
> Does anybody know how to call the ServiceInstall and
> ServiceProcessInstall methods to install the service successfully?
>


 
Reply With Quote
 
David Browne
Guest
Posts: n/a
 
      25th Nov 2004

"Burga" <(E-Mail Removed)> wrote in message
news:C73F2C8D-A4A9-4212-840F-(E-Mail Removed)...
>I have a simple service written in VB.net that can be installed and removed
> successfully using srvinst. I'd like to make this file self installing
> though
> (for example, run from the command line with an argument to get it
> instantiated in the SCM). I've done this in the past by calling
> createprocess
> WinAPI directly... but I'm guessing there must be a way to do this better
> in
> VB.Net. I began looking at calling the Install method on ServiceInstaller
> and
> ServiceProcessInstaller, but anything I try fails with a crash. From what
> I
> can tell, MS does not expect you to write to these methods as they are to
> be
> called by install programs. Usage and examples are hard to find.
>
> Does anybody know how to call the ServiceInstall and ServiceProcessInstall
> methods to install the service successfully?


Create your service following this walkthrough
http://msdn.microsoft.com/library/de...pplication.asp

You will add an installer class to your service assembly. This installer
class knows how to intall or install your service. Usually the installer
class is invoked by the InstallUtil utility. Here's a description of what
InstallUtil does

Installutil.exe uses reflection to inspect the specified assembly and find
all Installer types with the RunInstallerAttribute set to true. The tool
then executes either the Install Method or the Uninstall Method on each
instance of the Installer type. Installutil.exe performs installation in a
transactional manner; if one of the assemblies fails to install, it rolls
back the installations of all other assemblies. Uninstall is not
transactional.

http://msdn.microsoft.com/library/de...allutilexe.asp


Here's an article on how to write your own code to invoke your installer, so
you don't need installUtil

http://groups.google.com/groups?selm...&output=gplain


David


 
Reply With Quote
 
=?Utf-8?B?QnVyZ2E=?=
Guest
Posts: n/a
 
      29th Nov 2004

Thanks David. I tried making that work, but I get the following exception
when I try to set the context.
An unhandled exception of type 'System.NullReferenceException'
occurred in system.configuration.install.dll

Additional information:
Object reference not set to an instance of an object.

I am working in VB.net, so I had to change the provided code a little from
the c# sample. I experimented a little also, and the following is what I
currently have:

Dim ti As New TransactedInstaller
Dim mi As New ProjectInstaller
Dim cmdline(1) As String

ti.Installers.Add(mi)
cmdline(0) =
System.Reflection.Assembly.GetExecutingAssembly().Location
ti.Context = (New InstallContext("", cmdline))
ti.Install(New Hashtable)

Any idea why I should be getting that exception when setting ti.exception?
This might be really obvious to someone who has done this before...

Thanks!


"David Browne" wrote:

>
> "Burga" <(E-Mail Removed)> wrote in message
> news:C73F2C8D-A4A9-4212-840F-(E-Mail Removed)...
> >I have a simple service written in VB.net that can be installed and removed
> > successfully using srvinst. I'd like to make this file self installing
> > though
> > (for example, run from the command line with an argument to get it
> > instantiated in the SCM). I've done this in the past by calling
> > createprocess
> > WinAPI directly... but I'm guessing there must be a way to do this better
> > in
> > VB.Net. I began looking at calling the Install method on ServiceInstaller
> > and
> > ServiceProcessInstaller, but anything I try fails with a crash. From what
> > I
> > can tell, MS does not expect you to write to these methods as they are to
> > be
> > called by install programs. Usage and examples are hard to find.
> >
> > Does anybody know how to call the ServiceInstall and ServiceProcessInstall
> > methods to install the service successfully?

>
> Create your service following this walkthrough
> http://msdn.microsoft.com/library/de...pplication.asp
>
> You will add an installer class to your service assembly. This installer
> class knows how to intall or install your service. Usually the installer
> class is invoked by the InstallUtil utility. Here's a description of what
> InstallUtil does
>
> Installutil.exe uses reflection to inspect the specified assembly and find
> all Installer types with the RunInstallerAttribute set to true. The tool
> then executes either the Install Method or the Uninstall Method on each
> instance of the Installer type. Installutil.exe performs installation in a
> transactional manner; if one of the assemblies fails to install, it rolls
> back the installations of all other assemblies. Uninstall is not
> transactional.
>
> http://msdn.microsoft.com/library/de...allutilexe.asp
>
>
> Here's an article on how to write your own code to invoke your installer, so
> you don't need installUtil
>
> http://groups.google.com/groups?selm...&output=gplain
>
>
> David
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
installing services Mukesh Microsoft ASP .NET 3 5th Oct 2006 03:52 AM
Installing Fax Services =?Utf-8?B?SmFtZXM=?= Windows XP General 9 14th Jul 2005 03:41 AM
Fax Services not installing =?Utf-8?B?TmlzaA==?= Windows XP General 0 11th Jul 2005 11:54 AM
Urgent: Installing Component Services without installing IIS 5.0 in Win2k? Joe Bloggs Microsoft Windows 2000 2 29th Mar 2005 04:33 PM
Installing fax services Troll Windows XP Print / Fax 1 26th Jan 2004 10:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:55 PM.