[Mono-dev] AssemblyInstaller

Kornél Pál kornelpal at gmail.com
Sat Sep 18 05:04:05 EDT 2010


Hi,

See 
http://msdn.microsoft.com/en-us/library/system.configuration.install.managedinstallerclass.installhelper.aspx

That page documents exactly what it does.

installutil.exe should be implemented as sometihng like the following 
(I've tried it and it works on MS.NET):

class Program
{
	static void Main(string[] args)
	{
		try
		{
			ManagedInstallerClass.InstallHelper(args);
		}
		catch (Exception ex)
		{
			Console.WriteLine(ex.Message);
		}
	}
}


Arguments accepted are documented here:
http://msdn.microsoft.com/en-us/library/50614e95.aspx

So all the functionality of installutil.exe should be moved to 
ManagedInstallerClass. Even the help screen comes as an exception.

Note that no version headers are not printed by ManagedInstallerClass 
that should remain in installutil.exe and some appropriate status code 
should be set on return as well.

Based on the following example I belive that 
IManagedInstaller.ManagedInstall does exactly the same except that 
exceptions are not returned:

class Program
{
	static void Main(string[] args)
	{
		try
		{
			IManagedInstaller installer = new ManagedInstallerClass();
			StringBuilder sb = new StringBuilder();
			foreach (string arg in args)
			{
				sb.Append('"');
				sb.Append(arg.Replace("\\", "\\\\").Replace("\"", "\\\""));
				sb.Append("\" ");
			}
			if (sb.Length > 0)
				sb.Remove(sb.Length - 1, 1);
			installer.ManagedInstall(sb.ToString(), 0);
		}
		catch (Exception ex)
		{
			Console.WriteLine(ex.Message);
		}
	}
}

A search for hInstall in Platform SDK headers resulted in matches only 
from MsiQuery.h. So that method is most likely used by Windows Installer 
and I would guess that at least errors are reported using hInstall 
rather than exceptions.

Kornél

Nicholas Salerno write:
> Vincent Povirk wrote:
>> I don't know much about these classes, but my impression was that
>> ManagedInstallerClass corresponds most directly to installutil.exe,
>> but that that class must use AssemblyInstaller. It seems installutil
>> duplicates some functionality of both of those, and it should probably
>> call on them instead.
>
> The ManagedInstallerClass is scarcely documented in MSDN (unlike the other classes in the System.Configuration.Install namespace).  Also, the description states that the class is not meant to be directly used by one's code.  I don't know much about this ManagedInstallerClass other than it doesn't seem to fit with the model established by the Installer class.  It doesn't derive from Installer.  It implements IManagedInstaller, an interface I don't know much about.
>
> I am familiar with the Installer class that derives from Component and is meant to be subclassed.  The AssemblyInstaller class seems to be the class to use if one wants to programmatically install and uninstall .NET components (without having to execute shell commands to instalutil).  I do this in Windows.
>
> If nobody has any objections I would like to submit a patch that implements the AssemblyInstaller class.
>
> Nicholas
>
> -----Original Message-----
> From: Vincent Povirk [mailto:madewokherd at gmail.com]
> Sent: Friday, September 17, 2010 10:41 PM
> To: Nicholas Salerno
> Cc: mono-devel-list at lists.ximian.com
> Subject: Re: [Mono-dev] AssemblyInstaller
>
> I don't know much about these classes, but my impression was that
> ManagedInstallerClass corresponds most directly to installutil.exe,
> but that that class must use AssemblyInstaller. It seems installutil
> duplicates some functionality of both of those, and it should probably
> call on them instead.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>


More information about the Mono-devel-list mailing list