This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Getting STA Error when ShowDialog from C# Custom Action
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 30, 2008
04:37 PM
Getting STA Error when ShowDialog from C# Custom Action
Hello,
I created a C# WPF window I would like display with ShowDialog when the user clicks on a button during the UI Sequence. I created a simple C# method that takes nothing and returns nothing that displays the dialog. I marked this method with "[STAThread]" attribute. I created a managed custom action that calls this method when the user clicks on a button. I am getting an exception "The calling thread must be STA, because many UI components require this"
Any ideas how to fix this problem?
Thanks!
Greg
I created a C# WPF window I would like display with ShowDialog when the user clicks on a button during the UI Sequence. I created a simple C# method that takes nothing and returns nothing that displays the dialog. I marked this method with "[STAThread]" attribute. I created a managed custom action that calls this method when the user clicks on a button. I am getting an exception "The calling thread must be STA, because many UI components require this"
Any ideas how to fix this problem?
Thanks!
Greg
(4) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 30, 2008
05:41 PM
FWIW, I figured out a workaround that seems to work okay. I create an STA thread that launches the dialog as follows:
[STAThread]
public void DisplayDialog()
{
try
{
Thread worker = new Thread(DisplayDialogInternal);
worker.SetApartmentState(ApartmentState.STA);
worker.Start();
worker.Join();
}
catch (Exception exp)
{
ExceptionUtil.DisplayError(exp);
}
}
public void DisplayDialogInternal()
{
try
{
SomeWPFWindow gui = new SomeWPFWindow();
gui.ShowDialog();
}
catch (Exception exp)
{
ExceptionUtil.DisplayError(exp);
}
}
[STAThread]
public void DisplayDialog()
{
try
{
Thread worker = new Thread(DisplayDialogInternal);
worker.SetApartmentState(ApartmentState.STA);
worker.Start();
worker.Join();
}
catch (Exception exp)
{
ExceptionUtil.DisplayError(exp);
}
}
public void DisplayDialogInternal()
{
try
{
SomeWPFWindow gui = new SomeWPFWindow();
gui.ShowDialog();
}
catch (Exception exp)
{
ExceptionUtil.DisplayError(exp);
}
}
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 30, 2008
10:37 PM
Also be sure to check out Deployment Tools Foundtion (DTF)
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 04, 2008
05:44 PM
Do you know of an example that shows how to use "Deployment Tools Foundtion (DTF)" from InstallShield?
Thanks,
Greg
Thanks,
Greg
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 04, 2008
06:19 PM
DTF packages it's CA as a standard Type1 CA so it is compatible interchangable with what InstallShield calls an "MSI DLL stored in the Binary table" custom action type.