The debugger was unable to trace the value of the variable and reported the exception during the previous period of debugging the code, ANISOMETRYT cannot evaluate expression because a thread is stopped at a point where garbage Collection is impossible, possibly because the code is optimized.
As shown in the following:
Found in the above code, there is a type of construction method with a number of parameters:
After finding the data, it was found that in. NET 3.5 and 32-bit applications, the total size of memory consumed by all parameters in a single method cannot exceed 256 bytes.
Reproduce the above phenomenon in a simple code:
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Runtime.InteropServices;usingSystem.Text;namespaceconsoleapplication1{classTestClass { Public voidTestparams () {MyObject mo=NewMyObject (); Console.WriteLine (mo.id); Bytes128 bytes128=NewBytes128 (); TestParams256 (bytes128, bytes128); } Private voidTestParams256 (Bytes128 bytes1281, Bytes128 bytes1282) {Console.WriteLine (bytes1281); } Private voidTestParams128 (Bytes128 bytes128) {Console.WriteLine (bytes128); } } structBYTES16 {intWord; intWord2; intWord3; intWord4; } structBytes32 {Bytes16 word16_1; BYTES16 Word16_2; } structBytes64 {Bytes32 word32_1; Bytes32 word32_2; } structBytes128 {Bytes64 word64_1; Bytes64 Word64_2; }}
View Code
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace consoleapplication1{ class MyObject { publicint ID { get; Set ; } }}
View Code
Run and break at the MO variable:
The two parameters of the method TestParams256 are bytes128,bytes128 as the struct value type, the passing time will take the value to pass, two parameters occupy 256 bytes, cause the above phenomenon to appear.
Workaround:
1. Compile as x64 bit program
2. Framework with. NET 4.0 or later
3. Define a struct value type as a class reference type
4. Split the method into several methods to ensure that each method passes a parameter that takes up less than 256 bytes of memory.
In addition, the above exception is only the impact of debugging, in the process of running the program will not have an impact.
The value of an expression cannot be evaluated because the thread is parked at a point that cannot be garbage collected (possibly because the code has been optimized)