0

Our C# application works fine in executable, but it will suddenly has no response in debug mode, and we have to stop the program via debug menu.

After investigation, it was found that there has no return in the execution of the following statement if json contain a very large json object.

jsonString = Json.Encode(json);

We are using System.Web.Helpers.Json to encode the json object, when the object getting large, it will cause timeout in debug mode. We have tried to add a watch for Json.Encode(json), it will return "Evaluation timed out".

Although it won't cause any problem in our production version, but it has problem in debugging the application as the application hang whenever executing this statement.

We also found that this problem only occurred in the Windows 7 machine, and there has no problem in Windows 10 machine. So we have to use the Windows 10 machine for debug.

It seems that there has some limitation in debug mode under Windows 7 which does not allow such long execution statement. May I know if there has any way to config such timeout setting in debug mode?

James MA
  • 323
  • 5
  • 14
  • is that particular code line getting executed in different thread? – Rahul Jun 22 '16 at 01:56
  • It is executed in UI thread. Our major usage is to save all running data when application exit. – James MA Jun 22 '16 at 01:59
  • Also, is it happening on *all* win7 machines, or only one of them? (just trying to establish if it's OS-specific, or more environmental on that PC) – NPras Jun 22 '16 at 02:03
  • I just tested in one Windows 7 machine, as most of the workstations have been upgraded to Windows 10, we just keep one for production testing (as some of our client still using Windows 7). However, it has no problem in the executable, but it cause problem if we need to debug in Windows 7. – James MA Jun 22 '16 at 02:15
  • 1
    This may be worth trying as well: http://stackoverflow.com/questions/787334/how-to-keep-visual-studio-debugger-visualizers-from-timing-out – NPras Jun 22 '16 at 02:17
  • Thanks NPras. I can't find the setting under HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\Debugger\, but the setting under 12.0 also works in Visual Studio 2015 . – James MA Jun 22 '16 at 02:59

2 Answers2

1

Thanks NPras, you are right. The problem is in the json of System.Web.Helper only. I just try to modify one of the slow conversion code and execute the following two statement in debug mode,

string jsonString = Json.Encode(json);

string json2 = Newtonsoft.Json.JsonConvert.SerializeObject(json);

The output string has around 33K, the first one take over 20 seconds, while the second one can return in 1s, and the result is identical.

And one more finding, such slow performance in System.Web.Helper only occurred in the code running in background thread. For those running in UI thread, it has the same performance as the executable. Maybe, during debug mode, it is waiting for someone in UI thread which is blocked by Visual Studio IDE .

James MA
  • 323
  • 5
  • 14
0

Thanks NPras.

Although we are now using Visual Studio 2015, and there does not have the entry of "LocalsTimeout" under "HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\14.0\Debugger\".

But the problem can be solved by changing the setting of "LocalsTimeout" under "HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\Debugger\".

It seems that this setting is shared in different versions.

CORRECTION: - Really interesting, it only work for one time. Maybe after I change the setting, the json is not big enough for my testing. - I tested again, there still have no return. - I have increased the value to 10000, it seems not possible that it need 10 seconds for processing, but still no return.

James MA
  • 323
  • 5
  • 14
  • I wonder if the issue is in System.Web itself. Have you tried `Newtonjoft.Json`? – NPras Jun 27 '16 at 04:06
  • It need to study how to convert the program to use Newtonsoft.Json, as it has not provide same function as in System.Web.Helper. But I have tested again and again, and I found that it takes less than 1 second in executable, while it takes over 20 seconds to convert the same object in debug mode. – James MA Jul 04 '16 at 07:24