简体   繁体   中英

Debug Microsoft SharePoint code - disable optimization

I want to debug Microsoft code on SharePoint site.

I download .NET Reflector Visual Studio Extension so I can step into Microsoft code, but when I try to get the value of some variables - I get the error: "Cannot obtain value of local or argument <this> as it is not available at this instruction pointer, possibly because it has been optimized away."

I try to cancel the optimization, I saw what Cameron MacFarland wrote here , So I created a file with the commands that open VS without JIT optimizations. As for the second action - I do not know how to do it when it comes to a SharePoint application that IIS is running it.

How to achieve this?

EDIT: My question is basically: How to disable code optimization when the code is run by IIS?

I posted the answer here , and then saw that it also applied to your specific question.

Long story short, there is a registry setting you can change to make this work. Add a string key called "COMPLUS_ZAPDISABLE" to your registry at "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment". Set the key value to "1"

This original Red Gate article helped me find this trick.

The solution I did in the end, Is more or less what JaredPar wrote here :

I created a file that looks like this:

[.NET Framework Debugging Control] 
GenerateTrackingInfo=1 
AllowOptimize=0

And I put it in the GAC, within each folder of dll I wanted to disable its optimization, and named it with the name of the dll, with the extension "ini".

Now, the vast majority of variables are available to me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM