Windows phone 8 Windows phone参数异常

Windows phone 8 Windows phone参数异常,windows-phone-8,Windows Phone 8,我收到的错误是“System.Windows.ni.dll中发生了“System.ArgumentException”类型的异常,但未在用户代码中处理” void Touch\u FrameReported(对象发送方,touchframeventargs e) { int pointsNumber=e.GetTouchPoints(img1).Count;\\n我在这一行中得到了异常 TouchPointCollection pointCollection=e.GetTouchPoints(i

我收到的错误是“System.Windows.ni.dll中发生了“System.ArgumentException”类型的异常,但未在用户代码中处理”

void Touch\u FrameReported(对象发送方,touchframeventargs e)
{
int pointsNumber=e.GetTouchPoints(img1).Count;\\n我在这一行中得到了异常
TouchPointCollection pointCollection=e.GetTouchPoints(img1);
对于(int i=0;i

如何在Windows Phone 8中处理此异常

您需要像这样使用catch块进行try catch

 try { ... }
   catch(System.ArgumentNullException ane) { ... }
   catch(System.NotSupportedException nse) { ... }
   catch(System.IO.PathTooLongException ple) { ... }
   catch(System.IO.SecurityException se) { ... }
   catch(System.ArgumentException ae) { ... }

确保“System.ArgumentException”是您的最后一个捕获。如果需要,可以使用上面的4,您可能不需要路径处理程序…

我已经使用catch(System.ArgumentException ae){throw(ae)}了,但是应用程序变得非常慢。重点是确保“img1”变量永远不为null,并将条件放入GetTouchPoints()中,使其始终返回计数。这样,您就不必担心捕获sys异常。。
 try { ... }
   catch(System.ArgumentNullException ane) { ... }
   catch(System.NotSupportedException nse) { ... }
   catch(System.IO.PathTooLongException ple) { ... }
   catch(System.IO.SecurityException se) { ... }
   catch(System.ArgumentException ae) { ... }