OpenFileDialog fails on Win7 - wix

My installer needs to open a file browse dialog. As there is no file browse dialog provided by WIX I have written a C# dll containing a method to invoke the standard OpenFileDialog when called by a Custom Action. However while this works fine in Win2003 the Custom Action just hangs when run on Windows 7. It seems to get as far as the ShowDialog() call then stop. As a test I have written a separate Windows Forms app with a single dialog and button to invoke the OpenFileDialog and, as expected, that works fine. I just can't get the OpenFileDialog to appear from within my msi!
I suspect it may be a security thing so I ran the installer from msiexec opened as Administrator but with no difference!
Does anyone have any ideas how to fix this?
Many Thanks.

// create a new thread with appropriate apartment state to launch UI
OpenFileDialog fileBrowser = new OpenFileDialog();
Thread worker = new Thread(fileBrowser.Show);
worker.SetApartmentState(ApartmentState.STA); // <-- here is the magic code
worker.Start();
worker.Join();

When I attempted this I found it was popping up behind the other MSI windows. Until I figured this out, it looked just like a hang.
For this and a whole heap of other reasons, I ended up writing a bespoke install mechanism and ditching MSI. Much friendlier on the user and their system in the end.

Related

Why does Visual Studio start when opening a WindowsApplication.exe file?

I have a VStudio2012 solution for a Windows form app that has been compiled and runs fine for me when I launch it from myproject\bin\debug\utility.exe (the mainform comes up fine and the program runs fine).
I am trying to get a colleague familiar with the program and when he creates a shortcut to the above program and opens the utility.exe by doubleclicking it, then VStudio comes up instead of the mainform of the app.
Is there any way to achieve this without getting into some deployment scenario? I would like to leave this utility.exe where it is now and just get somebody else to run it from there? Is this possible?
Your friend is opening the .config file, not the .exe.
See "hide extensions for known file types"

Installer stopping service and giving file in use warning

I have a WiX installer project which installs a client app and a windows service. It is set to stop the service during install. However it still shows the error window "The following applications are using files which the installer must update" with the "Try Again", "Continue" and "Cancel" options. If I choose continue and inspect the windows event logs for the installer it shows the service being stopped and started again. The StopServices element is in the recommended sequence position.
How can I avoid the error window?
[Edit] My understanding is that it doesn't matter what order the files are listed as windows installer stops the service before copying any of them. I had wondered whether the service exe needed to be listed first.
Best solution: Use the "ServiceInstall" and "ServiceControl" elements to ensure the service is stopped/started (and installed/uninstalled) correctly.
In fact in our installer the app and service were being stopped/started from within custom installer code. However the check for whether the files are in use occurs before the custom installer code is run. So the files are in use when the installer starts, but are not in use by the time the installer attempts to copy the files. So annoying to the user, but not actually an issue. And if installed using msiexec.exe in quiet mode then the install succeeds.
Furthermore we had another issue with the service returned from the shutdown call, prior to actually having shutdown. (As commented by #PhilDW).

How can I get Explorer to restart when using Burn

In an msi, we use the following to get explorer to restart so that it loads our shell extension.
<util:RestartResource Path="[WindowsFolder]explorer.exe"/>
However, now that I've wrapped this msi up with its dependencies in an installer created with burn, the restart of Explorer no longer occurs.
How can I get the restart to still occur?
Thanks.
The msi normally displays some UI asking the user to reboot. This UI is hidden when wrapped in a burn/bundle exe. I thought perhaps the burn engine would issue callbacks allowing a custom bootstrapper to display the relevant UI. I tried overridding OnExecuteMsiMessage in a custom bootstrapper application, but don't see any message that would appear to give me an opportunity to display the UI that's required for the Explorer.exe restart.

Deploying Outlook addin to a Citrix XenApp installation

I created an Outlook addin. It does nothing special, just adds a menu with one menu item. I followed the installer creation tutorial from http://blogs.msdn.com/b/mcsuksoldev/archive/2010/10/01/building-and-deploying-an-outlook-2010-add-in-part-2-of-2.aspx.
It installs and works properly on a normal windows desktop installation, but I cant figure out how to do it in a Citrix XenApp environment. I can install it using the installer in the same profile where the Outlook is installed successfully. But when Outlook is run, it is in the "Inactive Application Addins" section when I view it from the Trust Center menu, and it wont activate properly. If I open the Manage COM Addins menu, it displays "Load at Startup" as my addin's Load Behavior. If I try to activate it manually from this menu, nothing happens, and if I open it again, Load Behavior will change to "Not Loaded. The Managed Add-in Loader failed to initialize."
Anyone encountered this or something similar before? Thanks in advance.
If it's installing but inactive then it's probably throwing an exception upon startup.
I'd wrap all of your startup code (ThisAddIn_Startup function inside your ThisAddIn.cs) inside a try {} catch {} and log all errors out to disk so you can see why outlook is disabling your addin.
Have you tried setting the VSTO_SUPPRESSDISPLAYALERTS environment variable to see if you can get outlook to give you more info?
(BTW I have found outlook VSTO's to be flaky. Sometimes they just refuse to install and work.)

I am looking for information to make my windows form app self updating

I would like to make my windows form app self updating when it starts. Where can I find good information for that?
I am using Visual Studio 2008 VB.NET.
I like the click once approach. With this application I have an access db as the backend datastore. When the application self updates how can I be sure the mdb file is not overwritten?
What is the best way to self upgrade the mdb if their is a change to the mdb file but not loose the data?
If you deploy using ClickOnce, you get this functionality for free. I do not have any experience with this (yet), but I can point you to an article.
I have been using Click Once for years with very little problems.
I've written a custom automatic updater and basically, the way it works is this:
The whole application is essentially 3 parts:
A launcher .exe that's essentially like a bootstrapper
The launcher .exe has an embedded .exe resource that is used if the launcher .exe itself needs to be updated
The application dll's
When you start the application, the launcher app starts and checks via webservices if the dll's are up to date. If they are not, it downloads them to a temporary directory and then makes sure the checksums are all correct and overwrites the existing app libraries with the new ones. It's then loading the application's core assembly and calls a "Run" method via reflection.
Now, in our app we sometimes have the need to update the launcher itself and the way we achieved this is by embedding an .exe in the launcher .exe resources. If the launcher detects that there is a new launcher .exe available, it downloads it to a temp directory, then extracts the .exe and launches it. This extracted .exe simply shuts down the launcher process, copies the new launcher .exe over the old one and then starts the launcher process again.