1

According to Microsoft's documentation on Develop IPlugin implementations as stateless:

"Because the platform caches plug-in class instances, the constructor isn't called for every invocation of plug-in execution."

However, when testing this behavior, I'm seeing different results.

Code to reproduce:

public class TestPlugin : IPlugin
{
    private Guid ExecutionContextId { get; } = Guid.NewGuid();
    
    public void Execute(IServiceProvider serviceProvider)
    {
        var tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
        tracingService.Trace($"ExecutionContextId: {ExecutionContextId}");
    }
}

Expected behavior: based on the documentation, the same GUID should be logged multiple times because the plugin instance should be cached and reused.

Actual behavior: each execution logs a different GUID, indicating a new instance is created each time.

Environment:

  • Dataverse Online (Developer environment)
  • Plugin registered in Sandbox mode
  • Synchronous execution
  • Tested: August 2025

What I've tried:

  1. Verified the plugin is registered correctly
  2. Tested with multiple executions in quick succession
  3. Checked trace logs - definitely different GUIDs each time

Question: has the plugin execution model changed in Dataverse? Is the documentation outdated, or am I misunderstanding how plugin caching works?

If instances are no longer cached, this would affect plugin design patterns significantly.

3
  • Interesting, I will test this behavior this week. Will get back to you. Commented Aug 25 at 7:51
  • Thank you. I only tested this in the Development environment. Maybe the environment matters... Maybe in the production environment all the optimizations take effect and there we would see such behavior as Microsoft describes. I'm curious to hear about the results of your experiments. Commented Aug 25 at 9:08
  • To test caching, I believe a more effective approach would be to insert a class-level, non-static DateTime property, initialize it to DateTime.Now in the constructor, and trace it in the Execute method. Commented Oct 15 at 12:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.