none
ShowDialog hangs when used in Script Task on Vista

    Question

  • On Vista SP1, Framework 3.5 installed, means also KB110806 (automatically by Windows update)
     
    Simple project in SQL Server BI Development Studio
    just one script task with variable FileName as R/W variable and following code:
    ' Microsoft SQL Server Integration Services Script Task
    ' Write scripts using Microsoft Visual Basic
    ' The ScriptMain class is the entry point of the Script Task.
    Imports System
    Imports System.Data
    Imports System.Math
    Imports System.Windows.Forms
    Imports Microsoft.SqlServer.Dts.Runtime

    Public Class ScriptMain
    ' The execution engine calls this method when the task executes.
    ' To access the object model, use the Dts object. Connections, variables, events,
    ' and logging features are available as static members of the Dts class.
    ' Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
    '
    ' To open Code and Text Editor Help, press F1.
    ' To open Object Browser, press Ctrl+Alt+J.
    Public Sub Main()
    '
    ' Add your code here
    '
    Dim fdlg As OpenFileDialog
    MsgBox("I am displaying")
    fdlg = New OpenFileDialog()
    fdlg.Title = "Data File (AXA)"
    fdlg.InitialDirectory = ""
    fdlg.Filter = "All Excel files|*.xls"
    fdlg.FilterIndex = 2
    fdlg.RestoreDirectory = True
    MsgBox("I am still displaying")
    If (fdlg.ShowDialog() = DialogResult.OK) Then
    Dts.Variables("FileName").Value = fdlg.FileName
    Dts.TaskResult = Dts.Results.Success
    Else
    Dts.TaskResult = Dts.Results.Failure
    End If
    MsgBox("I would love to be displayed")
    End Sub
    End Class
    right click on script task, execute task
     
    Actual Results
    MsgBox("I am displaying"): ok
    MsgBox("I am still displaying"): ok
    no file dialog box
    no MsgBox("I would love to be displayed")
     
    Expected Results
    showing file dialog box
    showing last msgbox
    (as on Windows server 2003)

     

    Sunday, June 22, 2008 12:10 PM

Answers

  • Using OpenFileDialog..
    Just added (<ofd>.ShowHelp = true) to my SSIS script (SQL Server 2005/SP3 & Vista Ultimate/ SP1),
    and my hanging <ofd>.ShowDialog() is now (Miraculously) visible!

    Many thanks for this
    Saturday, June 06, 2009 2:05 AM

All replies

  • I ran into this myself, also on Vista SP1.  My code had worked fine until the first time I tried to run it after installing SP1.

    I just tried a bunch of stuff and it finally started working again.  There are some bool type parameters which have to be initialized for OpenFileDialog and SaveFileDialog before the ShowDialog() method will work.

    When I say that it "hangs" I mean that the dialog does not display but no exception is thrown and the system eventually throws in a little wait cursor to indicate that the program is getting time.  It doesn't hang the entire computer, fortunately, but the application has to be terminated.

    For OpenFileDialog the ShowHelp property must be explicitly set.
    For SaveFileDialog the ShowHelp, CreatePrompt, and OverwritePrompt properties must be explicitly set.

    It's not consistent though.  I've had SaveFileDialog work with just ShowHelp set in simple situations.  But I have an app which didn't start running again until I also set CreatePrompt and OverwritePrompt properties then it started working again.  They don't have to be set to true, they just have to be initialized to either true or false.

                OpenFileDialog ofd = new OpenFileDialog();
                ofd.ShowHelp = true;
                Console.WriteLine("Showing OpenFileDialog");
                ofd.ShowDialog();  // Hangs if ShowHelp is not set.
                Console.WriteLine("ShowDialog Done");
               
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.ShowHelp = true;
                sfd.CreatePrompt = true;
                sfd.OverwritePrompt = true;
                Console.WriteLine("Showing SaveFileDialog");
                sfd.ShowDialog(); // Hangs if some or all of the parameters above are not set.
                Console.WriteLine("ShowDialog Done");

    I hope this helps.  It's really nasty when you apply an OS "Fix" and your programs can no longer save their output.

    Monday, August 11, 2008 12:39 AM
  • Using OpenFileDialog..
    Just added (<ofd>.ShowHelp = true) to my SSIS script (SQL Server 2005/SP3 & Vista Ultimate/ SP1),
    and my hanging <ofd>.ShowDialog() is now (Miraculously) visible!

    Many thanks for this
    Saturday, June 06, 2009 2:05 AM
  • Thank you, tonyeminem ! setting showhelp to true solved my problem in BIDS 2008!

    Wednesday, September 02, 2009 7:46 PM
  • You are really a genius....  This ShowHelp really works even for VS2010.

    Thanks a lot

    Sunday, October 02, 2011 6:20 AM