How do I get the COMplusExceptionCode from a standard Exception that doesn't already have it in the GetMessage? Thank you very much.
try
{
...
}
catch(Exception ex)
{
// How do I get the COMplusExceptionCode from ex?
}
I'm aware that this was asked a long time ago, but for anyone still looking for an answer to this, there are a number of ways of finding the COMException code if Visual Studio hasn't generated a .NET Exception object for you.
You first need to add a break point into your COMException catch statement to catch the exception. Then do one of the following:
The easiest method is to use the debugging controls to step into the catch statement, where Visual Studio should display a warning icon underneath the exception... click on this to view the related .NET exception. If Visual Studio has not generated a related exception, keep reading.
Use Intellisense - put your mouse cursor over the name of the exception in the catch declaration and drill all the way down to the Non-Public members section.
Use the Quick Watch Window to view the exception object and drill down to the Non-Public members section as above.
Type System.Exception._COMPlusExceptionCode into the Immediate Window.
All you will see for methods 2-4 however, is a single code number that you will then have to search the internet to find a meaning for.
Related
Is there a way to make the Intellij debugger show me where an exception was thrown in my own code? For example, I am currently trying to use the function parseInt of the Integer class to convert a string into an int.
public static int inputAccountNumber(){
Scanner scan = new Scanner(System.in);
System.out.print("Insert account number: ");
return Integer.parseInt(scan.nextLine());
}
In this case, If I just press enter when the input comes up, then an exception is thrown in the Integer class itself (and the debugger stops to show me the exception). However, I don't really care where in the Integer class this exception was thrown, I only want to the debugger to tell me where in my own code this problem occured.
I tried looking in the settings for breakpoints (which is where I enabled the option for the debugger to stop at exceptions), but it doesn't look like it has an option that fixes my problem.
P.S.: I'm on Intellij IDEA 2022.3.1 (Community Edition).
I don't know guys but Visual Studio just start acting crazy , my code was working fine I just added one column to a listview added a line of code tested some things and then reloaded the project without saving it (just to revert the project to its last state) but now when I load the project and start debugging I get an exception when declaring a variable on a form i didn't even load it my project structure is like this :
|<Settings
Splash screen --> Main Form --><Equalizer
|<Tags
The above meant that my project starts with splash screen and after 3 seconds it loads the main form which acts like a home for the app and then from there you can do regular media player stuff and also call three other forms {settings, equalizer and tags}, so when I start the project the splash screen load normally, the second it tries to call main form it throws an exception on this piece of code
Dim extendedinfoarray As New List(Of String())
Here is the exception info :
System.ArgumentOutOfRangeException occurred
HResult=-2146233086
Message=DisplayIndex value is out of bounds. Value must be greater than or equal to 0 and less than or equal to number of columns minus 1.
Parameter name: DisplayIndex
ParamName=DisplayIndex
Source=System.Windows.Forms
StackTrace:
at System.Windows.Forms.ColumnHeader.set_DisplayIndex(Int32 value)
at MrAudio.TaggingForm.InitializeComponent() in D:\Visual Studio Project Files\MediaPlayerFullFormProj\MediaPlayerFullFormProj\TaggingForm.Designer.vb:line 1668
at MrAudio.TaggingForm..ctor() in D:\Visual Studio Project Files\MediaPlayerFullFormProj\MediaPlayerFullFormProj\TaggingForm.vb:line 8
I'm using .NET 4.6.1
So what can be causing Visual Studio to start throw a random exception like this, I thought it can't throw an exception when declaring a variable. Can it?
Thanks in advance,
PS: this is my first question on StackOverflow if I didn't provide enough details just ask.
The problem is related to the ListView itself after removing a column, adding another one and arranging it will cause this problem
Quick fix :
Edit form designer file search for the ListView settings section change the column arrange to the correct one , or remove all columns, compile and start, then add those columns again and that should fix the problem.
In Mono Develop 3.X, there is a menu option to configure exceptions we wish to break on (Run -> Exceptions).
But with Mono Develop 5.7 IDE it is no longer there?
Also Debugger is not breaking on exceptions.
Any idea How to get it back, probably some add-ins ?
Exception catchpoints are now in same dialog as breakpoints.
You can open this dialog via
Run->New Exception Catchpoint
Breakpoints pad has button "New Exception Catchpoint"
What is nice about this is, you can use conditional and counting filters and different conditions/counts for different exceptions and also print debugging text(tracepoint) instead of breaking.
Most common use case is to add "System.Exception" and check "Include subclasses".
I'm relatively new to XCode (4.5) and i've ran into some problems with finding an error.
My project has suddenly started throwing out the following error when I attempt a model segue to open a view where I can add an item to a list - this previously was working.
"...-[TestUnit isEqualToString:]: unrecognised selector sent to
instance 0x89d4250"
I've had a google around using breakpoints and I've added an "All Exceptions Breakpoint" to my breakpoints list but it's made no difference, my console still isn't terribly helpful to me (in my new eyes), I've no idea where in my project this error is...
I've used NSLog to trace out to the console and the error appears to be occuring within prepareForSegue and I've even commented out every occurence of isEqualToString within the project and the error is still thrown...
Would anyone mind giving me some much needed pointers to get to the bottom of this?
Many thanks,
Matt
Goto to Xcode -> breakpoint navigator -> add + -> "add exception Breakpoint" -> run project
once exception occur check where is crashed, Print objects reference,
it have desire value or not?
Failed to create component 'User Control 1'. the error message follows:
'System.NullReferenceException : Object reference not set to an instance of an object.
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object Component, Object Value)
.............. etc..........
What should I do to fix this error?
When a User Control won't load into the Visual Studio designer here is what you need to do. These instruction are for vb.net project but c# should be similar. Also, before doing this close all open windows (or at least the source and designer files of the control you are working on.)
One last thing. The FIRST thing you should do is ensure that restarting visual studio doesn't fix the problem. If not you can try the steps that follow. These instructions assume that the errant user controls are in control library project in visual studio. If not you should be able to adjust the directions a bit to get it to work but it is much easier when the control is in its own project.
Do the following:
Make the control library your startup project.
Open the properties for the control library project and click on the debug tab.
Under Start Action click the Start external program option and browse to the Visual Studio executable.
NOTE: what this means is that when you run your solution it will fire up another instance of Visual Studio instead of actually running your solution. The First Instance of Visual Studion (INSTANCE_1) will "host" a second instance of visual studio (INSTANCE_2) when you run it.
Run your solution. INSTANCE_2 will load.
Switch back to INSTANCE_1.
In INSTANCE_1 hit CTRL-ALT-E. This will open up the exceptions dialog box. Check On the THROWN column checkbox next to Common Language Runtime Exceptions.
NOTE: This will ensure that INSTANCE_1 will BREAK at ANY runtime error even if it is hit in a try block.
Switch to INSTANCE_2. In Solution Explorer double-click to open the errant user control.
You should find that INSTANCE_1 OF Visual Studio should have stopped at the line of code that caused the designer to not load the control. Fix the code (which usually means testing for IsNot Nothing before references an object properties...but could mean other things.)
Also, sometimes I find that the control WILL load in INSTANCE_2 instead of breaking on an error in INSTANCE_1. In that case just stop debugging...close INSTANCE_2. Save/Restart INSTANCE_1 and your problem will often have gone away.
The lesson is this. User Control MUST be able to load/reference all objects and their members in order to load it into the designer. So for User Controls that will be placed onto other containers I will usually design events to notify the parent rather than trying to push objects into the child control.
Hope this helps for future reference on this old question.
Seth
Instead of the error occurring when you open up a form for editing, it sounds like this is occurring when you are already editing a form and adding new user controls. A CodeProject article that was previously mentioned shows what to do in the case of a form not loading correctly, rather than a specific user control.
Does your user control have any properties that map to custom objects (i.e. not Integer or String)? If so, the Form Designer will attempt to load your properties into the Property Editor. If showing the properties generates an error, the Form Designer will show that to you. I think this is what is happening with your user control.
If you could edit the question and add more information about the nature of the error (more of the error text), it would assist others in helping you better. Alternatively, see if you can find the property that might be causing the error (e.g. whether any property relies on a non-null value being set). You can also take a look at this MSDN article for tips on how to limit the control for just run-time.
Thanks, Seth, for this post! Your solution helped me nail down the error. The only thing I would add to this is that when "INSTANCE_2" loads, you may need to actually load the project file in INSTANCE_2. I needed to because I wasn't dealing with a control library, but instead had custom User Controls defined in the same project that the forms were located in. Once I loaded the project in INSTANCE_2, I opened the erring form and that caused INSTANCE_1 to pop up to the line of offending code in the User Control.
I have found that this error often occurs when control dlls are not building properly. 95% of the time this is remedied by simply restarting Visual Studio.