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
>
>
>