Forum Discussion

carstenw's avatar
carstenw
Creator II
9 years ago

How to debug a generic method

Hi, I do my fair share of developing in .net and use remote debugging in Visual Studio to that end. This works fine, until we come to generic methods. When my code enters the applyMethod() like so

var body = "<Item type='Method' action='gen_GetRequestFromActivity'><itm_type>"+ activityItemType +"</itm_type><itm_id>"+ thisId +"</itm_id></Item>";
var partRequest = inn.applyMethod("gen_GetRequestFromActivity", body); 
it either completes or throws exception (mostly the latter). I would really like to enter my "gen_GetRequestFromActivity()" method implementation and set a breakpoint to see what happens inside of it. I have putting the ol'

if (System.Diagnostics.Debugger.IsAttached)
{
    System.Diagnostics.Debugger.Break();
}
at the top of the generic method, to no avail. How do I get to debug the generic method when called from another method? Thanks in advance Carsten

4 Replies

  • To enable debugger, you need to:
    1. add following key to InnovatorServerConfig.xml <operating_parameter key="DebugServerMethod" value="true" />
    2. restart the IIS
    Be careful with this flag on Production environment, cause it can slow you production if you forgot to remove debugger from the code.
  • Hi Zahar, thanks for your reply. That key is already present in my InnovatorServerConfig.xml, and I am able to debug my other methods just fine. The issue arises when I use the Innovator method applyMethod("someMethod", "someParameters"); I would like to step into the someMethod() implementation, this is what is not working for me. Are you yourself able to step into a method called this way?
  • eli_donahue's avatar
    eli_donahue
    Community Manager
    Hi Carsten, Try the following steps after restarting IIS. 1. Open "Microsoft Visual Studio .NET 2012" debugger. 2. Choose Tools --> Attach to Processes…. 3. Choose w3wp.exe and click 'Attach'. 4. Choose Debug --> Exceptions to force the method into the debugger when an exception occurs and choose the check boxes "Thrown". 5. Optionally, you can include the line System.Diagnostics.Debugger.Break() to force a breakpoint at a specific line in your method. Eli Aras Labs Software Engineer
  • Is your generic method compiling correctly in the method editor? Instead of System.Diagnostics.Debugger.IsAttached in the generic method, try System.Diagnostics.Debugger.Launch(). I've never had a problem breaking in a generic method. Dennis