如果我的源代码中没有发生ArgumentOutOfRangeException异常,如何捕获? [英] How to catch ArgumentOutOfRangeException if it not happens in my source code ?

查看:152
本文介绍了如果我的源代码中没有发生ArgumentOutOfRangeException异常,如何捕获?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我正在尝试捕获ArgumentOutOfRangeException的异常,但是它发生在我在应用程序中使用的dll引用中.
我用Google搜索了此异常,但没有解决方案适合我.
我用try {} catch(ArgumentOutOfRangeException ex){}包围了使用该dll的代码,但仍会发生异常.

错误日志文件中有一些文字.

Hi All
I am trying to catch the exception of ArgumentOutOfRangeException but it happens in a dll reference which I use in my app.
I Googled this exception but no solution works for me.
I surround the code which I use this dll with try{}catch(ArgumentOutOfRangeException ex){} but exception still occur.

there is some text of error log file.

"Exception:
System.ArgumentOutOfRangeException: The added or subtracted value results in an un-representable DateTime.
Parameter name: value
   at System.DateTime.AddTicks(Int64 value)
   at Genetec.Sdk.Media.MediaPlayer.OnTimeLineRefreshTicks(Object sender, EventArgs e)
   at System.Windows.Threading.DispatcherTimer.FireTick(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)... "

推荐答案

用try..catch包围OnTimeLineRefreshTicks中对AddTicks的调用.以msdn为例.
http://msdn.microsoft.com/en-us/library/system.argumentoutofrangeexception.aspx [^ ]

祝你好运!
You would probably need to surround the call to AddTicks in OnTimeLineRefreshTicks with the try..catch. Have a look at msdn for an example.

http://msdn.microsoft.com/en-us/library/system.argumentoutofrangeexception.aspx[^]

Good luck!


看看这个线程是否可以帮助你

http://community.mediabrowser.tv/permalinks/1807/mediabrowser-不能播放某些avi-s [ ^ ]
See if this thread can help you

http://community.mediabrowser.tv/permalinks/1807/mediabrowser-fails-to-play-some-avi-s[^]


我做了这个,但此异常不再出现了
I made this and this exception did not appear again
// this line is inside form Load
mediaPlayback.Dispatcher.UnhandledException += OnUnhandeledException;

private void OnUnhandeledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            e.Handled = true;
        }


希望对您有帮助
谢谢大家
穆罕默德·贝赫里(Mohamed Behery)


I hope that help
thanks for all
Mohamed Behery


这篇关于如果我的源代码中没有发生ArgumentOutOfRangeException异常,如何捕获?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆