我正在做一个 WPF 应用程序,应用程序需要从 web 服务中获取数据。这些应用程序可以在我的 Visual Studio 中运行,但数据抓取需要 5 秒以上。但是,在我发布它并在另一台电脑上尝试之后,只要我点击搜索按钮,应用程序就会崩溃。我需要实现 try & catch 方法吗?有什么建议吗?
搜索按钮的代码片段:
private void serachBtn_Click(object sender, RoutedEventArgs e)
{
StoreApi.WebService myApi = new StoreApi.WebService();
var dbs = myApi.GetStorageInfo(0);
var query = from p in dbs
select new
{
Name = p.ProductName,
Price = p.ProductPrice,
};
myProductDataGrid.ItemsSource = query;
}
崩溃程序的图像:
问题详情:
Problem Event Name: CLR20r3
Problem Signature 01: beaconproject.exe
Problem Signature 02: 1.0.0.0
Problem Signature 03: 50dc1b77
Problem Signature 04: mscorlib
Problem Signature 05: 4.0.30319.17929
Problem Signature 06: 4ffa561c
Problem Signature 07: 2f1a
Problem Signature 08: 23
Problem Signature 09: System.FormatException
OS Version: 6.1.7601.2.1.0.256.4
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409