control.viewPort.CameraController.CameraRotationMode = CameraRotationMode.Turnball;
Throws helpful error
"An exception of type 'System.NullReferenceException' occurred in
your.exe but was not handled in user code"
RotateGesture works, also adding children, but not changes in RotationMode - why?
Related
I got this exception while try to update the badge count using the following below code
BadgeUpdater badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
// And update the badge
badgeUpdater.Update(badge);
It doesn't crash, all the exceptions I mention here can only be seen in Output window of Visual Studio. Here is the implementation of Dragging:
WPF:
<StackPanel Orientation="Vertical"
MouseDown="DragShortcut"
x:Name="Shortcut">
<Image Source="{Binding Icon}"/>
<Label Content="{Binding ShortcutLabel}"/>
</StackPanel>
cs code:
private void DragShortcut(object sender, MouseButtonEventArgs e)
{
if (e.LeftButton != MouseButtonState.Pressed)
return;
var dataObject = new DataObject(DataFormats.FileDrop, new[] { Options.DragDropOptions.ShortcutPath });
DragDrop.DoDragDrop(Shortcut, dataObject, DragDropEffects.Copy);
}
Everything seems to work as expected, but every time I drag something over my Desktop or Explorer window I receive the following messages in the Output window of my Visual Studio:
...
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
A first chance exception of type 'System.NotImplementedException' occurred in PresentationCore.dll
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll
...
When Visual Studio is set to stop on that kind of exceptions, I can see the following Exceptions:
System.Runtime.InteropServices.COMException was unhandled
Message: An exception of type 'System.Runtime.InteropServices.COMException' occurred in PresentationCore.dll and wasn't handled before a managed/native boundary
Additional information: Invalid FORMATETC-Structure (Exception HRESULT: 0x80040064 (DV_E_FORMATETC))
and
System.NotImplementedException was unhandled
Message: An exception of type 'System.NotImplementedException' occurred in PresentationCore.dll and wasn't handled before a managed/native boundary
Additional information: The method or operation is not implemented.
It doesn't lead to crash or anything, it's just uncomfortable for me as a developer to have such a thing happening in background. Does anyone have an Idea what could it be?
EDIT:
This problem looks a lot like mine, but seems to have another cause and solution.
This is entirely normal. Whatever window of another process you drag over will make that process poke the object you drag to see if it supports a particular format or can convert the object to another format. Done with COM calls under the hood. If the answer is "yes" then you see the cursor change to indicate that you can drop.
The IDataObject interface implementation in WPF says "no" by throwing an exception. The normal way in which COM failure codes are generated in a .NET program. That exception gets converted by the CLR into a COM error code, an HRESULT, to tell the process that it isn't going to work. Note how the Exeption class has the HResult property, that's what the process sees.
The debugger dutifully displays the "first chance" exception notification if you asked for it. Right-click the Output window, "Exception Messages" option, turned on by default. Nothing actually goes wrong, the exception is caught and handled gracefully. Feature, not a bug.
Visual studio 2013 often crashes when I use drag and drop functionality in winforms designer, like adding a new control, resizing controls, or just click on a control in order to see/change properties of the control. OS - Win 7x86, verson of VS - VS2013 ultimate 12.0.21005.1 rel. I tried to run VS as an administrator, but it still crashes almost all of the time when I use drag and drop functionality.
I debugged VS with the help of the second instance of VS(attached to a first VS process), here is the result: (i run it many times, it looks like that it throws 3 different kind of exception)
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Drawing.dll
Additional information: Object is currently in use elsewhere.
> System.Drawing.dll!System.Drawing.Image.RawFormat.get() Unknown
System.Drawing.dll!System.Drawing.Graphics.DrawImage(System.Drawing.Image image, int x, int y) Unknown
System.Design.dll!System.Windows.Forms.Design.Behavior.DesignerActionGlyph.Paint(System.Windows.Forms.PaintEventArgs pe) Unknown
Or the same exception but different call stack:
> System.Drawing.dll!System.Drawing.Graphics.FillRectangle(System.Drawing.Brush brush, int x, int y, int width, int height) Unknown
System.Drawing.dll!System.Drawing.Graphics.FillRectangle(System.Drawing.Brush brush, System.Drawing.Rectangle rect) Unknown
System.Design.dll!System.Windows.Forms.Design.Behavior.SelectionBorderGlyph.Paint(System.Windows.Forms.PaintEventArgs pe) Unknown
Another exception:
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
Additional information: Exception has been thrown by the target of an invocation.
> mscorlib.dll!System.Delegate.DynamicInvokeImpl(object[] args) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackDo(System.Windows.Forms.Control.ThreadMethodEntry tme) Unknown
System.Windows.Forms.dll!System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(object obj) Unknown
And the last one:
An unhandled exception of type 'System.AccessViolationException' occurred in System.Drawing.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
> System.Drawing.dll!System.Drawing.Graphics.FillRectangle(System.Drawing.Brush brush, int x, int y, int width, int height) Unknown
System.Drawing.dll!System.Drawing.Graphics.FillRectangle(System.Drawing.Brush brush, System.Drawing.Rectangle rect) Unknown
System.Design.dll!System.Windows.Forms.Design.Behavior.SelectionBorderGlyph.Paint(System.Windows.Forms.PaintEventArgs pe) Unknown
ETA: #GRUNGER 's answer helped, but what was the problem then?
It crashes even in a new empty project.
I have the same problem. Mouse cursor is blinking?
Try this (on admin mode CMD):
netsh winsock reset
Sometimes it helps, but the problem comes back after reboot.
This can be due to putting some dangerous/crashing code into constructor that prevents control from being created. Re-factor your code and move it to Load handler instead.
I have an ObservableCollection that a ListBox is databound to. I can add items to the ObservableCollection without issue, and the UI updates, but if I try to call either Remove or RemoveAt to allow the user to delete entries I end up with this:
'10Done.WindowsPhone.exe' (CoreCLR: .): Loaded
'C:\windows\system32\en-US\mscorlib.debug.resources.dll'. Module was
built without symbols. A first chance exception of type
'System.Runtime.InteropServices.COMException' occurred in
mscorlib.ni.dll An exception of type
'System.Runtime.InteropServices.COMException' occurred in
mscorlib.ni.dll but was not handled in user code Additional
information: Error HRESULT E_FAIL has been returned from a call to a
COM component.
Can I not remove items from a collection that is databound?
I'm receiving an unhandled exception while debugging, and the program stops executing. The debugger doesn't show me the line so I don't know what to fix.
An unhandled exception of type 'System.AggregateException' occurred in mscorlib.dll
Additional information: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread.
Cannot obtain value of local or argument '<this>' as it is not available at this instruction pointer, possibly because it has been optimized away. System.Threading.Tasks.TaskExceptionHolder
How can I troubleshoot this problem?
I also found this question which is pretty similar.
As the message says, you have a task which threw an unhandled exception.
Turn on Break on All Exceptions (Debug, Exceptions) and rerun the program.
This will show you the original exception when it was thrown in the first place.
(comment appended): In VS2015 (or above). Select Debug > Options > Debugging > General and unselect the "Enable Just My Code" option.
You could handle the exception directly so it would not crash your program (catching the AggregateException). You could also look at the Inner Exception, this will give you a more detailed explanation of what went wrong:
try {
// your code
} catch (AggregateException e) {
}
The accepted answer will work if you can easily reproduce the issue. However, as a matter of best practice, you should be catching any exceptions (and logging) that are executed within a task. Otherwise, your application will crash if anything unexpected occurs within the task.
Task.Factory.StartNew(x=>
throw new Exception("I didn't account for this");
)
However, if we do this, at least the application does not crash.
Task.Factory.StartNew(x=>
try {
throw new Exception("I didn't account for this");
}
catch(Exception ex) {
//Log ex
}
)
In my case I ran on this problem while using Edge.js — all the problem was a JavaScript syntax error inside a C# Edge.js function definition.