9

I’m trying to add a feature to my winforms app that prints the version number on the main screen. I currently have this:

txtVersion.Text = ProductVersion.ToString();

Which tells me the version of the program – all well and good.

However, what I’d ideally like it to do is to pick up the version of the installer program that was used to create the msi. Is there a way to either interrogate this from within the installed program, or to transfer the information during installation somehow?

4 Answers 4

4

It sounds like you want the ProductVersion property. You can get that at run time by calling the ::MsiGetProductInfo() function providing the ProductCode for the MSI that installed you.

If doesn't work out for you, then writing the ProductVersion to a registry key and reading that at run-time is fairly popular. You can use that registry key to solve the ICE38 troubles described here as well: http://robmensching.com/blog/posts/2007/4/27/How-to-create-an-uninstall-shortcut-and-pass-all-the

Sign up to request clarification or add additional context in comments.

2 Comments

But doesn't the ProductCode get updated each time the version number is increased?
If you do major upgrades, yes. If you are using major upgrades, then you can use ::MsiEnumRelatedProducts() and pass in your UpgradeCode (which should not be changing) to get the ProductCode then use the other APIs. Again, not trivial but not really hard either.
1

It's better not take app version from installer, but take installer version from app (AssemblyInfo.cs), imo.

Comments

0

You can save the version in a registry key during installation, and than query the registry key from the program.

Comments

0

You can very well do from your installation program (MSI) through custom actions using Wix3

Following links can get you started

WIX at Sourceforge

Wix Tutorial

1 Comment

Custom action isn't necessary for this, there is [ProductVersion] built in. Custom actions should be avoided at all costs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.