Of course it's hard to comment but because
is using COM interface under the hood. And there can be many reasons for a failure.
Let's assume that it is a problem with
. This can be fixed with something more conservative as this:
string productCode = mo["ProductIdentification"]; //not sure about exact name of the property
Process.Start("msiexec.exe", "/u "+productCode).WaitForExit();
If you want to hide the console window of msiexec.exe then you can adjust StartInfo to do so:
process.StartInfo.UseShellExecute = false;
Though quite possibly you don't have to go through this pain. If the product you are installing is the same product that you need to remove then you can find quite a few Upgrading samples in Wix# downloadables. This would be the best approach.
However if it is a different product then indeed you need to uninstall it manually. When doing so please be aware that if you are at active stage of installing the product you cannot do any other MSI activity (e.g. uninstall). Thus if it is in fact what you
are doing in your code then your
supposed to fail.
MSI only allows a single setup being active at the time. Though having setup GUI collecting user input is not part of this constrain. The "SimplifiedBootstrapper" sample exercises exactly this quality. It installs an additional dependency product
from UI sequence before starting the primary installation. In your case you want to uninstall instead of install.
Though... "SimplifiedBootstrapper" is a lab effort to allow chained installs/uninstalls before support for a proper WiX bootstrapper became available. Thus because now Wix# is fully integrated with Burn (WiX bootstrapper building tool) you can evaluate
if it can be used for the task. Typically botstrapper chains all required installs and all uninstalls. In your case you are doing a mixed operation uninstall-on-install so I am not sure how and if Burn supports it. You may need to do some research for this.
But... for something "quick and dirty", not as I am promoting it :), you may consider SimplifiedBootstrapper.