I have a strange problem with Visual Studio 2008 in only one of my projects. When I set a breakpoint on a line of code, it gets in shock, but when I try to "step over" or something else that needs to go through this breakpoint and stop on the next line, the code will execute and continue as if I hit F5. This happens even if I have another breakpoint on the line immediately after it, and, oddly enough, the second breakpoint is ignored (sometimes).
Anyone any ideas?
UPDATED
Here is a sample code. But it seems that anywhere I have a try ... catch block in which an exception is thrown, I have this problem.
In the following code example, "return (T) bFormatter.Deserialize (mStream)" throws an exception.
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();
}
}
source
share