Thursday, June 27, 2013

WiX Installer with custom bootstrapper

If anyone writing a custom bootstrapper for the wix installer in .net, then something might be useful. If you are using splash screen then you need to manually close it by using the following code:

First you register splashscreen inside bundle element:

<Bundle .. SplashScreenSourceFile="splash.bmp">

and then you need to close it using the following code:

public Bootstrapper(BootstrapperApplication installer)
{
   ...
   installer.Engine.CloseSplashScreen();
}

Took me a while to find as there is no documentation regarding this.

Visual Studio .NET 2012 Toolbox crash

Visual Studio .NET 2012 Toolbox Issues

If someone encounters the issue with VS crashing when adding toolbox items, especially Systems.Activities Components. The issue happens when you add a custom workflow activity to the toolbox and then decide to  update it by overwriting the original dll. After that when you open the "choose items..." dialog, the VS.NET will crash. Below is the solution to resolve this.

Looking through reflector I located the special folder where the cached elements for toolbox are saved. They are located under:

c:\Users\{User}\AppData\Roaming\Microsoft\VisualStudio\11.0 

and the file called WorkflowElement.cache. Simply delete the file and toolbox should work for you.

The error that you will get in Event Viewer:

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ArgumentNullException
Stack:
   at Microsoft.VisualStudio.Shell.Design.VsTargetFrameworkProvider.IsSupportedType(System.Type)
   at Microsoft.VisualStudio.Activities.ActivitiesToolboxPage.UpdateEntries()
   at Microsoft.VisualStudio.Activities.ActivitiesToolboxPage.OnActivate(System.ComponentModel.CancelEventArgs)
   at Microsoft.VisualStudio.Shell.DialogPage+DialogSubclass.WndProc(System.Windows.Forms.Message ByRef)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at Microsoft.VisualStudio.PlatformUI.NativeMethods.SendMessage(IntPtr, Int32, IntPtr, IntPtr)
   at Microsoft.VisualStudio.Toolbox.ClientControlledPageHost.SendNotification(Int32)
   at Microsoft.VisualStudio.Toolbox.ClientControlledPageHost.SetActive()
   at Microsoft.VisualStudio.Toolbox.ChooseItemsDialog+<>c__DisplayClass7.<SetClientPageActiveOnIdle>b__6()
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame)
   at System.Windows.Window.ShowHelper(System.Object)
   at System.Windows.Window.Show()
   at System.Windows.Window.ShowDialog()
   at Microsoft.Internal.VisualStudio.PlatformUI.WindowHelper.ShowModal(System.Windows.Window, IntPtr)
   at Microsoft.VisualStudio.PlatformUI.DialogWindow.ShowModal()
   at Microsoft.VisualStudio.Toolbox.ChooseItemsService.ShowChooseItemsDialog(System.Guid ByRef)
   at Microsoft.VisualStudio.Shell.Interop.IVsUIDataSource.Invoke(System.String, System.Object, System.Object ByRef)
   at Microsoft.Internal.VisualStudio.PlatformUI.DataSource.Invoke(System.String, System.Object, System.Object ByRef)
   at Microsoft.VisualStudio.PlatformUI.VsCommand.Execute(System.Object)
   at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(System.Windows.Input.ICommandSource, Boolean)
   at System.Windows.Controls.MenuItem.InvokeClickAfterRender(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(System.Object)
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at Microsoft.VisualStudio.PlatformUI.NativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.<PushMessageLoopOnContextMenuTrackingComponent>b__69(System.Object, Microsoft.VisualStudio.PlatformUI.OleComponentSupport.PreTranslateMessageEventArgs)
   at Microsoft.VisualStudio.PlatformUI.OleComponentSupport.OleComponent.FPreTranslateMessageCore(Microsoft.VisualStudio.OLE.Interop.MSG[])
   at Microsoft.VisualStudio.PlatformUI.OleComponentSupport.OleComponent.Microsoft.VisualStudio.OLE.Interop.IOleComponent.FPreTranslateMessage(Microsoft.VisualStudio.OLE.Interop.MSG[])
   at Microsoft.VisualStudio.OLE.Interop.IOleComponentManager.FPushMessageLoop(UInt32, UInt32, IntPtr)
   at Microsoft.VisualStudio.Platform.WindowManagement.WindowManagerService.PushMessageLoopOnContextMenuTrackingComponent()