我收到错误“System.Windows.ni.dll中发生类型'System.ArgumentException'的异常,但未在用户代码中处理”
void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
int pointsNumber = e.GetTouchPoints(img1).Count; \\ I got the Exception in this Line
TouchPointCollection pointCollection = e.GetTouchPoints(img1);
for (int i = 0; i < pointsNumber; i++)
{
if (pointCollection[i].Action == TouchAction.Down)
{
preXArray[i] = pointCollection[i].Position.X;
preYArray[i] = pointCollection[i].Position.Y;
}
if (pointCollection[i].Action == TouchAction.Move)
{
line = new Line();
line.X1 = preXArray[i];
line.Y1 = preYArray[i];
line.X2 = pointCollection[i].Position.X;
line.Y2 = pointCollection[i].Position.Y;
line.Stroke = new SolidColorBrush(Colors.White);
line.StrokeStartLineCap = PenLineCap.Round;
line.StrokeEndLineCap = PenLineCap.Round;
line.StrokeThickness = 20;
img1.Children.Add(line);
preXArray[i] = pointCollection[i].Position.X;
preYArray[i] = pointCollection[i].Position.Y;
}
}
}
如何在Windows Phone 8中处理此异常
答案 0 :(得分:0)
你需要尝试捕获这样的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,您可能不需要路径处理程序...