Click here to Skip to main content
15,908,274 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
--------------------------------------------------------------------------
MSIL
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]
Posted
Updated 16-May-11 22:54pm
v5

The code is working fine in my system,it might be a problem with JIT.Uninstall JIT and try the same code.
 
Share this answer
 
please provide the piece of code, not only the error.
 
Share this answer
 
Comments
parmar_punit 17-May-11 5:03am    
you can put this in comment... don't add solution with this kind of message...
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....
 
Share this answer
 
Comments
ambition13509 17-May-11 5:28am    
Hi Punit
Thanx for testing the code.
This is working fine on my machine also if I use this code in any another application.
but in same applicaiton if I use the same code anywhere it thrown me the same error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900