Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7065603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:58:35+00:00 2026-05-28T04:58:35+00:00

My WIX installer launches an immediate custom action. The custom action starts a WPF

  • 0

My WIX installer launches an immediate custom action.
The custom action starts a WPF dialog prompting the user for a BD connection parameters (I basically wrote the ‘new connection’ DB prompter dialog in WPF, to get me a connection string that the custom action can inject in the installed application’s configuration file).
The WIX code is fairly simple to figure out, and I know I execute the custom action just fine – I put there a MessageBox and a MmsiBreak on the call to my custom action method. I get there without a problem.
When the custom action instantiates my WPF dialog window, I get an InvaliOperationException: “The calling thread must be STA, because many UI components require this”.

The same code runs fine when I put it in a standard WPF application, because VisualStudio generates boiler plate code with Main() that has a STAThreadAttribute on it.
I can’t tack that attribute on the msiexec caller, and if I try to set the thread apartment state in my custom action, it fails:

Thread.CurrentThread.SetApartmentState(ApartmentState.STA);

Is not supposed to work for framework past 2.0.

Is there any way to do what I’m trying to do here? I’d appreciate some pointers.


EDIT

I even tried to run the dialog in its own thread, e.g. the code is like this:

// Static class members
static ManualResetEvent _done = new ManualResetEvent(false);
static ActionResult _caResult;
static Session _session;
static Thread _worker;

[CustomAction]
static public ActionResult PromptForDB(Session session)
{
    _session = session;
    _worker = new Thread(WorkerThread);
    _worker.Start();
    _done.WaitOne();
    return _caResult;
}

[STAThread]
static void WorkerThread()
{
    try
    {
        Prompter wnd = new Prompter();
        if (!(bool)wnd.ShowDialog())
        {
            _caResult = ActionResult.SkipRemainingActions;
        }
        else
        {
            // Harvest our properties (omitted from this post)
            _caResult = ActionResult.Success;
        }
        catch (Exception ex)
        {
            _caResult = ActionResult.Failure;
            _session.Log("Error: " + ex.Message);
        }
        finally
        {
            _done.Set();
        }
    }

That does not work either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:58:35+00:00Added an answer on May 28, 2026 at 4:58 am

    Before starting your new thread, set its ApartmentState as follows:

    _worker.SetApartmentState(ApartmentState.STA);
    

    See this:
    The calling thread must be STA, because many UI components require this in WPF

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WiX installer project that utilises a custom dialog box to ask
Is it possible to create (prefferably with WiX) windows installer dialog with hyperlink, which
I am creating WiX installer to drop my custom VS 2010 extension inside Visual
I'm trying to create a WiX installer dialog that provides a series of textboxes
We currently have a Database Project, which we wrote a WIX Installer for to
I have this bit in a Component in my WIX Installer <util:User Id=CIUSER CreateUser=yes
I'm using a wix installer to install a windows service using an existing user
I have created a wix installer project which is working fine. It installs my
I am using the WiX installer to install an application, and I need to
I have a WiX installer that I would like to check for .Net 3.5,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.