Unhandled Exception Overflow Winforms app - graphics

Overflow error.Inner Exception is :Stack Trace: at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
at System.Drawing.Graphics.DrawPath(Pen pen, GraphicsPath path)

I was trying to draw scan plane on DICOM image for next scan using just Leadtools AnnLineObject but for some reason value of endpoints for one of the lines was coming as double.NaN and windows would throw above an unhandeled exception while refreshing annotation or paint event. I could never find exactly which line of code threw the exception but changing my logic to avoid NaN coordinates fixed it.

Related

Android Studio - how to debug this situation?

Preface
I'm maintaining an app that I inherited from another team
Scenario
I understand ClassCastException but for the life of me I cannot find where this error is occurring in the code.
01-27 14:47:15.839 13272-13272/com.xx.android E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xx.android, PID: 13272
java.lang.ClassCastException: com.xx.viewmodels.components.AutoValue_SpecialViewModel cannot be cast to com.xx.viewmodels.components.NormalViewModel
at com.xx.android.viewholders.NormalViewHolder.bind(NormalViewHolder.java:27)
at com.xx.android.BaseAdapter.onBindViewHolder(BaseAdapter.java:39)
at com.xx.android.componentfeed.ComponentFeedAdapter.onBindViewHolder(ComponentFeedAdapter.java:123)
at com.xx.android.componentfeed.ComponentFeedAdapter.onBindViewHolder(ComponentFeedAdapter.java:79)
at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6541)
at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5484)
at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5750)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5589)
at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5585)
at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2231)
at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1558)
at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1518)
at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:610)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3719)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3436)
at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3988)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.support.v4.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:611)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1585)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1494)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1742)
at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1731)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1496)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:132)
at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1361)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:874)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:344)
at android.widget.FrameLayout.onLayout(FrameLayout.java:281)
at android.view.View.layout(View.java:17938)
at android.view.ViewGroup.layout(ViewGroup.java:5814)
at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1171)
at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:856)
at android.support.design.widget.ViewOffsetBehavior.layoutChild(ViewOffsetBehavior.java:63)
at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:136)
at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1361)
at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:874)
at andro
(I'm not sure why the output cutoff at that point)
NormalViewHolder.java
line 27
public class NormalViewHolder extends ComponentViewHolder<NormalViewModel> {
lines 55-64
public NormalViewHolder(final View itemView, final RecyclerView.RecycledViewPool relatedItemsViewPool) {
super(itemView);
Dagger.getInstance(itemView.getContext()).inject(this);
ButterKnife.bind(this, itemView);
adapter = new NormalRelatedItemsAdapter();
recyclerView.setRecycledViewPool(relatedItemsViewPool);
recyclerView.setAdapter(adapter);
recyclerView.setNestedScrollingEnabled(false);
}
Question
The app stops abruptly even with the settings found in my screenshot below. I've set breakpoints all around bind and onBindViewHolder and followed them as far as they go with no avail. How can I go about tracking down this issue? I was thinking I could move around in a breakpoint to put things together but I'm not having any luck.. Suggestions?
Extra
In researching the issue I've adjusted my breakpoint settings to the following with no success:
This was an impossible situation to debug.
This app was written to leverage dagger modules. In the app there was a line that referenced an incompatible class but in a file that was never even mentioned in the stack trace - making my methods of debugging rather useless.
Ultimately I had to go through line by line, manually inspecting every situation. Good old fashioned elbow grease.

unrecognised exception in windows C++ code

We have a number of sections of code in the format:
try
{
// code
}
catch(std::exception &e)
{
// log exception
}
catch(...)
{
// log unknown exception.
}
Every so often, the unknown exception code triggers, and logs an unknown exception.
I always thought that all exceptions were meant to derive from std::exception, and thus catching std::exception would catch all exceptions.
Is there some other exception that I should be catching?
If my code ends up in the unknown exception handler, is there any way that I can find out what exception was actually caught?
edit
We managed to locate the cause of the problem- despite saying that they had, the customer had not installed .NET 3.5, which our code depends on, and the system fell over when trying to use the XML parser.
Is there some other exception that I should be catching?
This depends on your code. Libraries you call can throw exceptions not derived from std::exception, examples are MFC's CException or Microsoft's _com_error. Also, an access violation might be catched by catch(...), which is the reason why I would not use catch(...) in my code - it's just to broad for me.
2.If my code ends up in the unknown exception handler, is there any way that I can find out what exception was actually caught?
You can run your code in the debugger and configure the debugger to break your program when the exception is thrown (first chance). Then you know exactly which line of code triggers the exception and should be able to see what exactly is thrown.

Awesomium.NET WebCore.CreateWebView throughs unhandled exception

The following code throws an unhandled exception, and I have no clue why.
using (WebView view = WebCore.CreateWebView(1100, 600))
{
...
}
Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Awesomium.Core.NativeMethods.WebCore_CreateWebView_1(HandleRef jarg1, Int32 jarg2, Int32 jarg3, HandleRef jarg4)
at Awesomium.Core.WebCore.CreateWebView(Int32 width, Int32 height)
Any idea on how to solve this?
I had the same issue and it seems when the JavaScript is off, it will crash. So it's better to start WebCore.CreateWebSession with WebPreferences.Default instead of new WebPreferences with JavaScript = false.
Also its session needs a separate thread for the whole life of the application (just one thread and not more).

Debugging XAML UnhandledException

Occasionally the UnhandledException handler in my app is raised due to an unhandled XAML exception.
The UnhandledExceptionEventArgs contains the message
E_RUNTIME_SETVALUE
and an inner-exception of type ArgumentException
Value does not fall within the expected range.
There is nothing in the call stack other than InitialiseComponent() which I can step into/ over without any exception being thrown.
Any ideas on how to debug further or any experience with E_RUNTIME_SETVALUE issues?
I do remember I had to once add basically no-op value converters to some XAML so I could see what was going on and trace the error. That might help in this case as well.
Also try to turn on mixed-mode debugging to see if more data comes from the native stack.
I had this in UWP and it was because I was using OnIdiom
<OnIdiom x:Key="MyFontSize" x:TypeArguments="x:Double" Tablet="28" Phone="16">
</OnIdiom>
I didn't have desktop included in one of the values and I was running my app on my desktop.

Server.Transfer and System.Threading.ThreadAbortException

See http://support.microsoft.com/kb/312629/EN-US/
I am using reponse.direct in my app as well and I am not getting the exception. The workaround that the knowledge base article suggests (Server.Execute) does not work for me. I am getting lots of javascript exceptions from the Ajax Toolkit on the target page if I use Server.Execute, and I did not dig into the cause.
My question - what arguments do you see against just swallowing the exception as a 'known limitation' and moving on?
My reason for using Server.Transfer in this one very specific case is that I want to mask the (real) target url of the page that is actually executing. It works pretty well, except for this exception (that the user never sees).
Make sure you are not calling Server.Transfer() within an exception handler (try..catch/finally).
Edit:
Server.Transfer always raises ThreadAbortException upon completion. If you wrap it in an exception handler you should trap for explicit exception types instead of just 'Exception'.
See the help for Server.Transfer on MSDN. Here is info about ThreadAbortException

Resources