在C#.net中的OpenFileDialog.Showdialog上引发错误 [英] Throwing error on OpenFileDialog.Showdialog in c#.net

查看:129
本文介绍了在C#.net中的OpenFileDialog.Showdialog上引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在XP机器中开发Windows应用程序.以我的一种形式,我有一个文本框用于显示带有openfiledialog框路径的所选文件.另一个控件是用于调用openfiledialog框的按钮.
当我按一下按钮以调用打开的对话框时,出现以下错误
-------------------------------------------------- ------------------------------

有关调用的详细信息,请参见此消息的末尾
即时(JIT)调试,而不是此对话框.

**************例外文字**************
System.Runtime.InteropServices.COMException(0x80040154):由于以下错误,检索具有CLSID {DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7}的组件的COM类工厂失败.
   在System.Windows.Forms.OpenFileDialog.CreateVistaDialog()
   在System.Windows.Forms.FileDialog.RunDialogVista(IntPtr hWndOwner)
   在System.Windows.Forms.FileDialog.RunDialog(IntPtr hWndOwner)
   在System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window所有者)
   在System.Windows.Forms.CommonDialog.ShowDialog()
   在GroundMaster.cs:line 974中的iSAP2.GroundMaster.btnBrowse_Click(Object sender,EventArgs e)中
   在System.Windows.Forms.Control.OnClick(EventArgs e)
   在System.Windows.Forms.Button.OnClick(EventArgs e)
   在System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   在System.Windows.Forms.Control.WmMouseUp上(消息和m,鼠标按钮按钮,Int32单击)
   在System.Windows.Forms.Control.WndProc(Message& m)
   在System.Windows.Forms.ButtonBase.WndProc(Message& m)
   在System.Windows.Forms.Button.WndProc(Message& m)
   在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)处
   在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)处
   在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)

-------------------------------------------------- ------------------------ 


这是我的按钮事件代码
-------------------------------------------------- ------------------------

私有 void  button1_Click(对象发​​件人,EventArgs e)
        {


            OpenFileDialog openfiledialog = new OpenFileDialog();   
            openfiledialog.Filter = "   ;   
            openfiledialog.Multiselect = false ;   
            DialogResult dr ;   
            dr = openfiledialog.ShowDialog();   

            如果(dr == DialogResult.OK)
            {
                txtgrdDataFile.Text = openfiledialog.FileName.ToString();   
           }

       }
-------------------------------------------------- --------------------------- 



表单的其余部分包含另一个控件,例如数据网格和下拉列表.
请帮助我解决此问题.

提前感谢.

问候,
苏达珊

[edit]忽略HTML ..."选项已禁用-OriginalGriff [/edit]
[edit2]在其中添加了lang属性并关闭了PRE标签[/edit]

解决方案

该代码在我的系统中运行正常,可能是JIT问题卸载JIT并尝试相同的代码. 这段代码可以在我的机器上完美运行...
这可能是您电脑中的其他问题....


Hi Everybody,
I am developing a windows application in XP machine.in my one form i have one text box for showing the selected file with path from openfiledialog box.and the other control is button to call the openfiledialog box.

When I cliked on the button to call the open dialog box I am getting the follwing error
--------------------------------------------------------------------------------

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {DC1C5A9C-E88A-4DDE-A5A1-60F82A20AEF7} failed due to the following error: 80040154.
   at System.Windows.Forms.OpenFileDialog.CreateVistaDialog()
   at System.Windows.Forms.FileDialog.RunDialogVista(IntPtr hWndOwner)
   at System.Windows.Forms.FileDialog.RunDialog(IntPtr hWndOwner)
   at System.Windows.Forms.CommonDialog.ShowDialog(IWin32Window owner)
   at System.Windows.Forms.CommonDialog.ShowDialog()
   at iSAP2.GroundMaster.btnBrowse_Click(Object sender, EventArgs e) in GroundMaster.cs:line 974
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

--------------------------------------------------------------------------


Here is my code on button event
--------------------------------------------------------------------------

private void button1_Click(object sender, EventArgs e)
        {


            OpenFileDialog  openfiledialog = new OpenFileDialog();
            openfiledialog.Filter = "xml files|*.xml";
            openfiledialog.Multiselect = false;
            DialogResult dr;
            dr = openfiledialog.ShowDialog();

            if (dr == DialogResult.OK)
            {
                txtgrdDataFile.Text = openfiledialog.FileName.ToString();
           }

       }
-----------------------------------------------------------------------------



rest of the form contains another controls like data grid and dropdowns.
Please help me to resolve this issue.

Thanx in advance.

Regards,
Sudarshan

[edit]"Ignore HTML..." option disabled - OriginalGriff[/edit]
[edit2] Added the lang attribute and closing PRE tag to it [/edit]

解决方案

The code is working fine in my system,it might be a problem with JIT.Uninstall JIT and try the same code.


please provide the piece of code, not only the error.


private void button1_Click(object sender, EventArgs e)
{
            OpenFileDialog openfiledialog = new OpenFileDialog();
            openfiledialog.Filter = "xml files|*.xml";
            openfiledialog.Multiselect = false;
            DialogResult dr;
            dr = openfiledialog.ShowDialog();
            if (dr == DialogResult.OK)
            {
                MessageBox.Show("You have clicked ok");
            }
}


This code is perfectly running on my machine...
It may be other problem in your pc....


这篇关于在C#.net中的OpenFileDialog.Showdialog上引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆