Tip #51: What to do if your Plugin won’t Trigger or Debug when Registered on SetState

If you register a plugin on SetState, most of the time you can’t get it to trigger or debug.  Register it instead on the (technically deprecated) SetStateDynamicEntity message. It should work fine.

Note: Instead of “Target”, the entity in the context for the entity being activated or deactivated, the new context input parameter will be called “EntityMonker”. This is easily cast-able to EntityReference though by this method:


EntityReference _entity =
   (EntityReference ) _context.InputParameters["EntityMoniker"];

– Don’t forget to tip your tipster!

4 thoughts on “Tip #51: What to do if your Plugin won’t Trigger or Debug when Registered on SetState

  1. Marten Rading says:

    Hi,

    I try to run a plugin on these two states. When I load the errordetails file from the profiler I get this error:

    Unhandled Exception: System.ArgumentException: Unable to parse the OrganizationServiceFault.

    <snip>

    I have tried a completly empty plugin (necessary code in it ofc but no actions performed). Any ideas on what could be the issue? I have tried to download new versions of the sdk and a bunch of other things.

  2. Stanza says:

    Hi,

    Try using ‘Persist to Entity’ option rather than ‘Exception’ option when Profiling.

    I was getting what you were getting and this helped me get arround that error message.

    Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *