Blog Archives
DLL in Stored Procedure MSSQL
Extended Stored Procedures (MSDN), http://support.microsoft.com/kb/190987
Thread Local Storage in an extended stored procedure (MSDN), http://support.microsoft.com/kb/163449
C# Create a Windows Installer Class Custom Action bootstrap DLL in .Net
The standard windows installer project included with Visual Studio right out of the box is great in many deployment scenarios.
For more advanced needs, organizations and developers usually defer to 3rd party solutions, such as InstallShield, Wise, wix or NSIS (NullSoft).
These solutions are all very well tested and have minimal learning curve in a lot of cases. However, if you are tight on budget or simply looking for the experience and full customization, you can also create your own custom action installer class in Visual Studio.
Simply create a new DLL project included in the same solution as your windows installer project. From the Windows Installer Project go to “File System” and in your Application Folder add “Project Output” and select your new DLL. Now go to the “custom actions” tab and under install and/or uninstall right click and “Add Custom Action” then select the output under Application Folder. That’s it!
Make sure the class for your DLL has “RunInstaller” attributes and looks similar to the snippet below. You may also want to do some light reading on the “CustomActionData” property to see if there are any variables you may need such as “ProductCode”.
To change the custom action data property, from the custom action tab simply select your DLL output after adding it, and expand the Visual Studio Properties tab on the side.
using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Configuration.Install; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.InteropServices; namespace MSIBootstrap { [RunInstaller(true)] public partial class InstallHelper : Installer { public static string InstallTitle = "Discount Notes"; //used by install/uninstall to get window handle public InstallHelper() { InitializeComponent(); } public override void Install(System.Collections.IDictionary stateSaver) { try { //your custom code base.Install(stateSaver); } catch (Exception ex) { throw new InstallException(ex.ToString()); } } public override void Uninstall(System.Collections.IDictionary stateSaver) { //mimic same try/catch design pattern if you like base.Uninstall; } }
With this approach, you are essentially using the standard windows installer project to bootstrap your custom action DLL.
This is very powerful, and allows you to define your own code logic and conditions as well as custom interfaces and forms designed directly from within Visual Studio.
References
InstallShield, http://www.flexerasoftware.com/products/installshield.htm
Wise installer, http://www.wise.com/Products/Installations/WiseInstallerEvaluations.aspx
wix installer, http://wix.sourceforge.net/
Nullsoft NSIS, http://nsis.sourceforge.net/Download
Wikipedia (bootstrapping), http://en.wikipedia.org/wiki/Bootstrapping_%28computing%29
devx.com, http://www.devx.com/dotnet/Article/20849/1954
PCReview.co.uk, http://www.pcreview.co.uk/forums/install-project-custom-action-failure-t2612207.html
codefounders.com (persisting savedState), http://www.codefounders.com/community/blogs/davidg/archive/2007/06/27/persisting-state-in-a-windows-installer-managed-custom-action.aspx
MSDN, “CustomActionData”, http://msdn.microsoft.com/en-us/library/2w2fhwzz(v=vs.80).aspx