COMPUTER_LZY

要输就输给追求,要嫁就嫁给幸福

导航

对话框必须由用户启动

Sliverlight4中打开客户端文件,debug时会报这个错误!

 

                OpenFileDialog ofld = new OpenFileDialog();
                ofld.Multiselect = false
                bool flag = (bool)ofld.ShowDialog();
                 if (flag == true)
                {
                    string name = ofld.File.Name;
                    Stream stream = ofld.File.OpenRead();

                    stackpanel_工作表选择.Visibility = Visibility.Collapsed;
                    excel_xml_worksheet_import = new madamingExcelXMLWorkSheetImport(stream);
                    stackpanel_工作表选择.Visibility = Visibility.Visible;

                    combobox_工作表选择.Items.Clear();
                    for (int i = 0; i < excel_xml_worksheet_import.WorkSheets.Count(); i++)
                    {
                        ComboBoxItem c = new ComboBoxItem();
                        c.Content = excel_xml_worksheet_import.WorkSheets[i].WorksheetName;
                        combobox_工作表选择.Items.Add(c);
                    }
                    if (combobox_工作表选择.Items.Count() > 0) combobox_工作表选择.SelectedIndex = 0;
 }   

   当将断电设置在下列代码中或之前时就会报错:

  OpenFileDialog ofld = new OpenFileDialog();

ofld.Multiselect = false
bool flag = (bool)ofld.ShowDialog();

 

将断点设置在其后就可以了!原因可能是在生成ofld示例后到ShowDialog之前不能有时间上的停顿 

posted on 2012-06-15 14:17  CANYOUNG  阅读(1974)  评论(0编辑  收藏  举报