Cannot obtain value of local or argument as it is not available at this instruction pointer, possibly because it has been optimized away

后端 未结 17 2159
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 16:12

Visual Studio 2010 kills (there is no other word) data in one of the arguments of the function in the unsafe block. What could cause this error? The following message shows

17条回答
  •  日久生厌
    2020-11-29 16:54

    Had the same issue before with a WPF application and all the solutions here did NOT solve the issue. The problem was that the Module was already optimized so the following solutions DO NOT WORKS (or are not enough to solve the issue):

    • "Optimize Code" checkbox un-Checked
    • "Suppress JIT optimization on module load" checked
    • Solution configuration on DEBUG

    The module is still loaded Optimized. See following screenshot:


    To SOLVE this issue you have to delete the optimized module. To find the optimized module path you can use a tool like Process Hacker.

    Double click your program in the "Process panel" then in the new window open the tab ".NET Assemblies". Then in the column "Native image path" you find all Optimized modules paths. Locate the one you want to de-optimize and delete the folder (see screenshot below): (I blurred my company name for obvious reasons)

    Restart your application (with check box in step 1 correctly checked) and it should works.

    Note: The file may be locked as it was opened by another process, try closing Visual Studio. If the file is still locked you can use a program like Lock Hunter

提交回复
热议问题