<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Register .NET asembly windows installer class</Title>
      <Shortcut>Register.NETasemblywindowsinstallerclass</Shortcut>
      <Description>Register .NET asembly windows installer class [C#]</Description>
      <Author>J.Marc Piulachs</Author>
      <HelpUrl>/PreviewSnippet.aspx?SnippetID=c38b3f5e-4dcf-4477-8fa2-552e06accdda</HelpUrl>
      <SnippetTypes>
        <SnippetType>SurroundsWith</SnippetType>
      </SnippetTypes>
    </Header>
    <Snippet>
      <Code Language="csharp"><![CDATA[	[RunInstaller(true)]
	public class InstallClassRegAsm: Installer
	{
		public InstallClassRegAsm() :base()
		{
		}
		#region Install
		//---Override the 'Install' method.
		public override void Install(IDictionary savedState)
		{
			base.Install(savedState);
			//---the assembly to register
			string strAssemblyFile = base.Context.Parameters["name"].ToString();
			//---checkpoint 
			Trace.WriteLine(string.Format("Install {0}", strAssemblyFile));
			//---load assembly 
			Assembly objAsm = Assembly.LoadFrom(strAssemblyFile);
			
			//---action
			RegistrationServices  objRS = new RegistrationServices();
			objRS.RegisterAssembly(objAsm, AssemblyRegistrationFlags.SetCodeBase);		
		}
		#endregion
		#region Uninstall
		//---Override the 'Uninstall' method.
		public override void Uninstall(IDictionary savedState)
		{
			base.Uninstall(savedState);
			//---the assembly to register
			string strAssemblyFile = base.Context.Parameters["name"].ToString();
			//---checkpoint 
			Trace.WriteLine(string.Format("Uninstall {0}", strAssemblyFile));
			//---load assembly 
			Assembly objAsm = Assembly.LoadFrom(strAssemblyFile);
	
			//---action
			RegistrationServices  objRS = new RegistrationServices();
			objRS.UnregisterAssembly(objAsm);	
		}
		#endregion
	}]]></Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>