1

I've got a Wix Managed Bootstrapper Application written in WPF.

After a certain change was made, the bootstrapper no longer works: When I run the WPF project without the Bootstrapper it runs fine (UI shows at least). But when I run the Bootstrapper itself it opens an empty (black background) window that just sits there and does nothing.

The breaking change seems to be moving the main view MainView.xaml into a View subfolder. Of course even with this change the WPF project itself still runs fine, but just the Bootstrapper is broken as mentioned.

I did some searching and the closest info I could find was this http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Visual-Styles-in-Wix-BA-td7584971.html where the suggestions included:

1) use pack://application:,,, i.e absolute paths for all resources: I tried this but it did not fix my issue

2) add the extra files as Payload elements: This seems to only apply for non-embedded resources so it doesn't apply to me

3) Add Application.ResourceAssembly = typeof(MainWindow).Assembly; to the Bootstrapper: I don't know what this does and I don't know where to add it so I haven't tried it.

How can I fix this issue?

Additional info: The breaking change: I moved the my MainView XAML file from the root directory of the WPF application to a subfolder named View. I moved several ResourceDictionary XAML files from /View/ to /View/Dictionaries/. I used absolute paths to access these moved XAML files, something like:

<ResourceDictionary Source="WindowStyle.xaml" />

was changed to

<ResourceDictionary Source="/View/Dictionaries/WindowStyle.xaml" />

Note that the absolute paths I used started with a slash, but did not start with pack://application:,,,.

Image resources: In case it is relevant, any images I had were placed in the Resources folder, with their properties Build action = Resource and Copy to output directory = Do not copy. I used the images like this:

<Image Source="/Resources/logo.png" VerticalAlignment="Center" Width="75" Height="25" />
user145400
  • 1,076
  • 1
  • 12
  • 27

2 Answers2

1

The solution was the opposite of suggestion 1) in my question. In other words, I had to use relative paths everywhere in my XAML and NOT absolute paths. The Wix BS must be moving things around, so absolute paths don't work but relative paths do since everything that moves will move together and still be in the same relative location.

user145400
  • 1,076
  • 1
  • 12
  • 27
  • There must be more to it then that. Sean Hall is a WiX developer who's worked on burn. – Christopher Painter Dec 05 '14 at 02:20
  • I have to agree, there's not enough detail here to help someone else. Are you doing [what WixBA does](http://stackoverflow.com/a/25122360/628981)? – Sean Hall Dec 09 '14 at 01:10
  • I do have a couple images resources.. but as I mentioned in my question the problem was not just images, it was even XAML not being located properly at runtime. What do you mean not enough detail? It's a Wix managed bootstrapper using WPF. What other detail do you need? – user145400 Dec 09 '14 at 16:03
  • 1
    XAML is always compiled by default, you would have to have code explicitly reading XAML files at runtime for that to matter. You mention that you have embedded images, but don't explain how you embedded them (there are multiple ways to do this). You don't mention how you're using the embedded resources (XAML, code behind, or something else). You must have changed something in your XAML or code after you moved the file to make it work, you could at least give the lines before and after you made the change. – Sean Hall Dec 10 '14 at 00:46
  • Added more info as you requested. Is this not a common issue/question from people using WPF for their Wix BAs? If I get a chance and if you're willing to look at it, I might be able to prepare a small VS solution to demonstrate the issue. – user145400 Dec 10 '14 at 16:38
1

Application.ResourceAssembly (ManagedBootstrapperApplicationHost is an unmanaged application that hosts .NET and the WPF assembly).

You would call this as soon as possible, i.e. in the parameterless constructor of your BootstrapperApplication, where MainWindow is a type in the DLL which contains the embedded resources. This allows you to use pack://application:,,, style references.

public class MyBA : BootstrapperApplication
{
    public MyBA()
    {
        if (Application.ResourceAssembly == null)
        {
            Application.ResourceAssembly = typeof(MainWindow).Assembly;
        }
    }
}
Sean Hall
  • 7,629
  • 2
  • 29
  • 44
  • + 1 Thanks, that makes sense now. I think this is a possible alternative solution to what I did, but not necessarily preferable (in my case relative paths work fine and are less typing than absolute paths, and I don't have to worry about setting the ResourceAssembly). – user145400 Dec 08 '14 at 20:10