1

I have a sandbox feature, and I've added two event receivers - FeatureActivated and FeatureInstalled. The FeatureInstalled event handler executes, if I attach to the SPUCWorkerProcess and the SPUCHostProcess I can debug the code. However, my breakpoints in the FeatureActivated code are not hit. Also, though in the project properties I have selected the No activation option, in the Solution gallery the feature is always activated.

How can I debug the FeatureActivated event handler in a sandboxed solution? I've also tried Debugger.Break, but it does not work.

kjv
  • 11,047
  • 34
  • 101
  • 140

2 Answers2

1

Features don't go in the Solution gallery, only solutions do. You need to attach to all of the w3wp processes and the SPUCWorkerProcesses then go to Site settings -> site features and manually activate. It should hit your breakpoint then.

KyleM
  • 4,445
  • 9
  • 46
  • 78
0

There are couple of options:

  • Use System.Diagnostics.Debugger.Launch() to launch the debugger irrespective of where the feature is activated.

  • Use DebugView and use Debug.WriteLine() to write debug statements.

Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124
  • Can you explain the issues you faced – Madhur Ahuja Jun 05 '11 at 00:00
  • I am not even sure that the code in my event handler is executing. Debugger.Break() and Debugger.Launch() do not trigger the VS debugger dialog. The breakpoints in the Installed / Uninstalled event handlers work as expected. – kjv Jun 06 '11 at 23:13
  • If you select No Activation. It won't be called. Just because it shows "Activated" doesn't mean that it will be activated everytime you install the solution. – Madhur Ahuja Jun 07 '11 at 01:20