【发布时间】:2009-02-02 09:43:28
【问题描述】:
在我的一个项目中,Visual Studio 2008 出现了一个奇怪的问题。当我在一行代码上设置断点时,它会正常运行,但是当我尝试“跳过”或其他任何应该越过该断点并在下一行停止的东西时,代码就会被执行并继续,好像我按 F5 一样。即使我在这一行之后有另一个断点,也会发生这种情况,奇怪的是,第二个断点被忽略(有时)。
任何人,有什么想法吗?
更新
这是一个示例代码。但似乎在我有一个抛出异常的 try...catch 块的任何地方,我都有这个问题。
在以下代码示例中“return (T)bFormatter.Deserialize(mStream)”会引发异常。
public static T LoadEncryptedObject<T>(string location) where T : class
{
if( string.IsNullOrEmpty(location) || !System.IO.File.Exists(location) )
return default(T);
System.IO.FileStream fs = null;
try
{
fs = new System.IO.FileStream(location, System.IO.FileMode.Open,
System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite);
BinaryFormatter bFormatter = new BinaryFormatter();
byte[] encryptedBytes = new byte[fs.Length];
fs.Read(encryptedBytes, 0, encryptedBytes.Length);
MemoryStream mStream = new MemoryStream(Cryptography.Decrypt(encryptedBytes));
return (T)bFormatter.Deserialize(mStream);
}
catch( SerializationException sx )
{
System.Diagnostics.Debug.WriteLine(sx.Message);
return default(T);
}
finally
{
if( fs != null )
fs.Close();
}
}
【问题讨论】:
-
你能提供那个“bug”的截图吗(你可以使用JING:jingproject.com)
-
什么类型的代码?赢表格?网络表格? wpf?控制台?
-
那么你是说如果你在 System.Diagnostics.Debug.WriteLine(sx.Message);行,那个断点永远不会被命中?
-
没有。如果我在例如“fa = new ...”上放置一个断点,它将命中,但是当我跨过 (F10) 时,它将跳转到“return (T)bFormatter.Deserialize(mStream)”行,这将抛出一个例外。
-
奇怪。您是否尝试过构建-> 重建解决方案?几乎听起来 pdb 文件已经过时了......
标签: visual-studio-2008 debugging