OpenFileDialog exceptions
-
Hi All! The standard OpenFileDialog throws exceptions when I call its
ShowDialog
method. I have all Exceptions activated (Menu Debug->Exceptions) and also the "Enable unmanaged code debuging" in the project properties -> Debug settings. When I turn off this last option the dialog doesn't throw any exception. As my project deals with homemade libraries both mnaged and unmanaged I do have to debug the unamanaged code too. So disabling unmanaged debugging isn't a solution.public AForm()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog(); //The exceptions are thrown from here
}Here is what I have for exceptions: exception: GCError at memory location 0x0019d9d8.. exception: [rethrow] at memory location 0x00000000.. exception: CNLBaseException at memory location 0x065ebcb8.. RPC Server unavailable Does anyone had this problem before or knows how to get red of those exceptions? Thanks in advance!
-
Hi All! The standard OpenFileDialog throws exceptions when I call its
ShowDialog
method. I have all Exceptions activated (Menu Debug->Exceptions) and also the "Enable unmanaged code debuging" in the project properties -> Debug settings. When I turn off this last option the dialog doesn't throw any exception. As my project deals with homemade libraries both mnaged and unmanaged I do have to debug the unamanaged code too. So disabling unmanaged debugging isn't a solution.public AForm()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog(); //The exceptions are thrown from here
}Here is what I have for exceptions: exception: GCError at memory location 0x0019d9d8.. exception: [rethrow] at memory location 0x00000000.. exception: CNLBaseException at memory location 0x065ebcb8.. RPC Server unavailable Does anyone had this problem before or knows how to get red of those exceptions? Thanks in advance!
I think you may have to check some of the initialisation values are set correctly; see here[^] for more details. [edit] I have reproduced the code exactly as above and it works fine, so I must assume the actual eception is caused somewhere else, and it just appears to be at that point. Can you explain how you are so sure it is caused by the
ShowDialog()
method? [/edit]Unrequited desire is character building. OriginalGriff
-
Hi All! The standard OpenFileDialog throws exceptions when I call its
ShowDialog
method. I have all Exceptions activated (Menu Debug->Exceptions) and also the "Enable unmanaged code debuging" in the project properties -> Debug settings. When I turn off this last option the dialog doesn't throw any exception. As my project deals with homemade libraries both mnaged and unmanaged I do have to debug the unamanaged code too. So disabling unmanaged debugging isn't a solution.public AForm()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog(); //The exceptions are thrown from here
}Here is what I have for exceptions: exception: GCError at memory location 0x0019d9d8.. exception: [rethrow] at memory location 0x00000000.. exception: CNLBaseException at memory location 0x065ebcb8.. RPC Server unavailable Does anyone had this problem before or knows how to get red of those exceptions? Thanks in advance!
-
Hi All! The standard OpenFileDialog throws exceptions when I call its
ShowDialog
method. I have all Exceptions activated (Menu Debug->Exceptions) and also the "Enable unmanaged code debuging" in the project properties -> Debug settings. When I turn off this last option the dialog doesn't throw any exception. As my project deals with homemade libraries both mnaged and unmanaged I do have to debug the unamanaged code too. So disabling unmanaged debugging isn't a solution.public AForm()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog(); //The exceptions are thrown from here
}Here is what I have for exceptions: exception: GCError at memory location 0x0019d9d8.. exception: [rethrow] at memory location 0x00000000.. exception: CNLBaseException at memory location 0x065ebcb8.. RPC Server unavailable Does anyone had this problem before or knows how to get red of those exceptions? Thanks in advance!
There shouldn't be any problems provided your main method is managed, has the [STAThread] attribute, and you create your AForm instance(s) from the main thread. If you deviate from this path, you are set for trouble with COM objects such as OpenFileDialog. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
Hi All! The standard OpenFileDialog throws exceptions when I call its
ShowDialog
method. I have all Exceptions activated (Menu Debug->Exceptions) and also the "Enable unmanaged code debuging" in the project properties -> Debug settings. When I turn off this last option the dialog doesn't throw any exception. As my project deals with homemade libraries both mnaged and unmanaged I do have to debug the unamanaged code too. So disabling unmanaged debugging isn't a solution.public AForm()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog(); //The exceptions are thrown from here
}Here is what I have for exceptions: exception: GCError at memory location 0x0019d9d8.. exception: [rethrow] at memory location 0x00000000.. exception: CNLBaseException at memory location 0x065ebcb8.. RPC Server unavailable Does anyone had this problem before or knows how to get red of those exceptions? Thanks in advance!
public MainForm()
{
InitializeComponent();OpenFileDialog ofd = new OpenFileDialog(); ofd.ShowDialog(); //The exceptions are thrown from here }
I have copied the code into my program and it works perfectly. Perhaps you forget to Initialize some Components that are used by AFORM() and exceptions are thrown because of that, or you forget to initialize the OpenFileDialog itself if it is necesary, InitialDirectory,Filter... Try to use your code in different place, for example in subprogram, and call it from wanted place:
public AForm()
{
// calling subprogram
Openfiledialog();
}void Openfiledialog()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog(); //The exceptions are thrown from here
}If you dont get error messages again it is clear that something diferent is wrong with your program. For this exception I have found explenation, RPC Server unavailable: You are trying to connect to a remote server that is unavailable or does not exist. This error may be caused by your network connection being lost. For other exeptions I didnt. All the Best, Peric Zeljko (periczeljkosmederevo@yahoo.com)
-
public MainForm()
{
InitializeComponent();OpenFileDialog ofd = new OpenFileDialog(); ofd.ShowDialog(); //The exceptions are thrown from here }
I have copied the code into my program and it works perfectly. Perhaps you forget to Initialize some Components that are used by AFORM() and exceptions are thrown because of that, or you forget to initialize the OpenFileDialog itself if it is necesary, InitialDirectory,Filter... Try to use your code in different place, for example in subprogram, and call it from wanted place:
public AForm()
{
// calling subprogram
Openfiledialog();
}void Openfiledialog()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog(); //The exceptions are thrown from here
}If you dont get error messages again it is clear that something diferent is wrong with your program. For this exception I have found explenation, RPC Server unavailable: You are trying to connect to a remote server that is unavailable or does not exist. This error may be caused by your network connection being lost. For other exeptions I didnt. All the Best, Peric Zeljko (periczeljkosmederevo@yahoo.com)
Kudos for answering, but please place code inside a pre block either by using the code widget or manually using <pre> ... </pre> around the code. You can still do this by editing your response. I would not post your email address publicly in an online forum unless you really like spam!
Dave
Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) -
Looks more like your memory has become corrupted. You're not running the method from a different thread, are you?
Bastard Programmer from Hell :suss:
No I'm not, I call it from the main thread. The
Control.InvokeRequired
method returns alwaysfalse
. -
I think you may have to check some of the initialisation values are set correctly; see here[^] for more details. [edit] I have reproduced the code exactly as above and it works fine, so I must assume the actual eception is caused somewhere else, and it just appears to be at that point. Can you explain how you are so sure it is caused by the
ShowDialog()
method? [/edit]Unrequited desire is character building. OriginalGriff
It worked fine some time ago... You're right the exception could be caused somewhere else. I tested to disable only the
ShowDialog()
method call and it worked fine. No exceptions. When you ran the code, did you activate the "Unmanaged code debuging"? -
There shouldn't be any problems provided your main method is managed, has the [STAThread] attribute, and you create your AForm instance(s) from the main thread. If you deviate from this path, you are set for trouble with COM objects such as OpenFileDialog. :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
That's exactly what I did :(
-
public MainForm()
{
InitializeComponent();OpenFileDialog ofd = new OpenFileDialog(); ofd.ShowDialog(); //The exceptions are thrown from here }
I have copied the code into my program and it works perfectly. Perhaps you forget to Initialize some Components that are used by AFORM() and exceptions are thrown because of that, or you forget to initialize the OpenFileDialog itself if it is necesary, InitialDirectory,Filter... Try to use your code in different place, for example in subprogram, and call it from wanted place:
public AForm()
{
// calling subprogram
Openfiledialog();
}void Openfiledialog()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.ShowDialog(); //The exceptions are thrown from here
}If you dont get error messages again it is clear that something diferent is wrong with your program. For this exception I have found explenation, RPC Server unavailable: You are trying to connect to a remote server that is unavailable or does not exist. This error may be caused by your network connection being lost. For other exeptions I didnt. All the Best, Peric Zeljko (periczeljkosmederevo@yahoo.com)
That was a good clue! I disabled my network adapter to check if the network could cause the problem and the OpenFileDialog worked fine! As my "My Documents" folder is stored on a remonte server, my computer uses the network connection to get the folder and files informations. Any idea why this could throw the exceptions I have? I'm not sure yet why I have those exceptions, but my code isn't faulty! ;P