I'm using the latest Plugin Registration Tool (PRT), 9.1.0.167, installed through the PAC CLI process. Dataverse database version is 9.2.22111.00206.
When installing the Profiler I get the following error:
Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'CrmSdk.PluginType'.
at Microsoft.Crm.Tools.Libraries.OrganizationHelper.InstallProfiler(CrmOrganization org, String prtPath)
at Microsoft.Crm.Tools.PluginRegistration.OrganizationControlViewModel.<>c__DisplayClass302_0.<InstallProfiler_Clicked>b__2(Object o, DoWorkEventArgs e)
But the profiler solution is installed and the PRT will allow you to enable profiling.
The plugin runs successfully. Then we turn on profiling for the plugin step and when executing the exact same transaction receive the follow error:
When looking at the plugin trace we can see there is an infinite loop occurring in the profiler code that is eventually errors out:
Here is the error message content from the first trace (Depth = 1):
Exception type: System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]
Message: Unable to persist the profile.Detail:
<OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
<ActivityId>0107fa88-e11c-42ee-92ad-bbda48862d72</ActivityId>
<ErrorCode>-2147220891</ErrorCode>
<ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
<KeyValuePairOfstringanyType>
<d2p1:key>OperationStatus</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:int">3</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>SubErrorCode</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:int">-2146233088</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>Plugin.ExceptionFromPluginExecute</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">PluginProfiler.Plugins.ProfilerPlugin</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>Plugin.ExceptionRetriable</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:boolean">false</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>Plugin.ExceptionSource</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">PluginExecution</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>Plugin.OriginalException</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">PluginExecution</d2p1:value>
</KeyValuePairOfstringanyType>
<KeyValuePairOfstringanyType>
<d2p1:key>Plugin.PluginTrace</d2p1:key>
<d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">Getting PostUpdateImage
Getting afsdc_response from preMessageImage
Post - afsdc_response equals Yes
Unexpected Exception occurred in Profiler while persisting the profile:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: ISV code reduced the open transaction count. Custom plug-ins should not catch exceptions from OrganizationService calls and continue processing.
<OrganizationServiceFault xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ActivityId>07d7adb0-f7fd-42c8-8ade-a01a1fa437bd</ActivityId><ErrorCode>-2146893812</ErrorCode><ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic"><KeyValuePairOfstringanyType><a:key>ApiExceptionSourceKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">Api/PostPipeline</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiSourceActivityKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema"/></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiExceptionOwnerKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">OwnershipNotFoundInExceptionOwnerSettings</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiOriginalExceptionKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">Microsoft.Crm.CrmException: ISV code reduced the open transaction count. Custom plug-ins should not catch exceptions from OrganizationService calls and continue processing.&#xD;
at Microsoft.Crm.BusinessEntities.ExecutionContext.ThrowIfInvalidPluginTransaction(Int32 countThreshold)&#xD;
at Microsoft.Crm.BusinessEntities.ExecutionContext.CommitTransaction(ProcessDependenciesOption option, FlushCacheOption flushOption)&#xD;
at Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context)&#xD;
at Microsoft.Crm.Extensibility.InternalMessageDispatcher.&lt;&gt;c__DisplayClass5_0.&lt;Execute&gt;b__0()&#xD;
at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action, IEnumerable`1 additionalCustomProperties)&#xD;
at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action)&#xD;
at Microsoft.Crm.Extensibility.ExternalMessageDispatcher.ExecuteInternal(IInProcessOrganizationServiceFactory serviceFactory, IPlatformMessageDispatcherFactory dispatcherFactory, Guid callerRegardingObjectId, Int32 invocationSource, Version endpointVersion, OrganizationRequest request, OrganizationInternalRequest organizationInternalRequest)&#xD;
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.DispatchRequest(OrganizationRequest request, OrganizationInternalRequest organizationInternalRequest, SdkResponseDescription responseDescription, SdkPerformanceCounterContext sdkPerformanceCounterContext)&#xD;
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.ExecuteRequestRequestWithInstrumentation(OrganizationRequest request, OrganizationInternalRequest organizationInternalRequest)&#xD;
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.ExecuteRequestRequestWithInstrumentationOperation(OrganizationRequest request, OrganizationInternalRequest organizationInternalRequest)&#xD;
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.&lt;&gt;c__DisplayClass22_0.&lt;ExecuteRequest&gt;b__0()</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiStepKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">00000000-0000-0000-0000-000000000000</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiDepthKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">2</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiActivityIdKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">07d7adb0-f7fd-42c8-8ade-a01a1fa437bd</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiPluginSolutionNameKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">System</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiStepSolutionNameKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">System</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiExceptionCategory</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">ClientError</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiExceptionMessageName</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">IsvTransactionCount</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiExceptionHttpStatusCode</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">400</a:value></KeyValuePairOfstringanyType></ErrorDetails><HelpLink>http://go.microsoft.com/fwlink/?LinkID=398563&amp;error=Microsoft.Crm.CrmException%3a8009000c&amp;client=platform</HelpLink><Message>ISV code reduced the open transaction count. Custom plug-ins should not catch exceptions from OrganizationService calls and continue processing.</Message><Timestamp>2023-01-05T21:23:47</Timestamp><ExceptionRetriable>false</ExceptionRetriable><ExceptionSource>SdkClientError</ExceptionSource><InnerFault i:nil="true"/><OriginalException>System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: ISV code reduced the open transaction count. Custom plug-ins should not catch exceptions from OrganizationService calls and continue processing. (Fault Detail is equal to Exception details: &#xD;
ErrorCode: 0x8009000C&#xD;
Message: ISV code reduced the open transaction count. Custom plug-ins should not catch exceptions from OrganizationService calls and continue processing.&#xD;
TimeStamp: 2023-01-05T21:23:47.8013818Z&#xD;
--&#xD;
).</OriginalException><TraceText i:nil="true"/></OrganizationServiceFault>
at Microsoft.CDSRuntime.SandboxWorker.SandboxCallbackService.<>c__DisplayClass16_1.<ExecuteStreamingCallBack>b__1(ExecuteRequest response)
at Microsoft.CDSRuntime.SandboxWorker.SandboxCallbackService.GrpcClientSendAndReceive(ExecuteResponse executeResponse, Func`2 isTerminalResponse)
at Microsoft.CDSRuntime.SandboxWorker.SandboxCallbackService.<>c__DisplayClass16_0.<ExecuteStreamingCallBack>b__0()
at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action, IEnumerable`1 additionalCustomProperties)
at Microsoft.CDSRuntime.SandboxWorker.SandboxCallbackService.ExecuteStreamingCallBack(Func`2 callback, Func`2 isTerminalChunk, Func`2 HandleClientException)
at Microsoft.CDSRuntime.SandboxWorker.SandboxOrganizationService.Execute(String operation, ByteString serializedRequest, Assembly proxyTypes, Object traceSettings)
at Microsoft.CDSRuntime.SandboxWorker.SandboxOrganizationServiceWrapper.<>c__DisplayClass23_0.<ExecuteInternal>b__0()
at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)
at Microsoft.CDSRuntime.SandboxWorker.SandboxOrganizationServiceWrapper.ExecuteInternal(OrganizationRequest request)
at Microsoft.CDSRuntime.SandboxWorker.SandboxOrganizationServiceWrapper.CreateInternal(Entity entity)
at PluginProfiler.Plugins.ServiceWrappers.OrganizationServiceWrapper.Create(Entity entity)
at PluginProfiler.Plugins.ProfilerBase`1.Execute(T operationContext, ProfilerPluginContext context, ProfilerPluginReport report, Object inputParameter)
</d2p1:value>
</KeyValuePairOfstringanyType>
</ErrorDetails>
<HelpLink i:nil="true" />
<Message>Unable to persist the profile.</Message>
<Timestamp>2023-01-05T21:23:47.8013818Z</Timestamp>
<ExceptionRetriable>false</ExceptionRetriable>
<ExceptionSource>PluginExecution</ExceptionSource>
<InnerFault i:nil="true" />
<OriginalException>PluginExecution</OriginalException>
<TraceText>
Getting PostUpdateImage
Getting afsdc_response from preMessageImage
Post - afsdc_response equals Yes
Unexpected Exception occurred in Profiler while persisting the profile:
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: ISV code reduced the open transaction count. Custom plug-ins should not catch exceptions from OrganizationService calls and continue processing.
<OrganizationServiceFault xmlns="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ActivityId>07d7adb0-f7fd-42c8-8ade-a01a1fa437bd</ActivityId><ErrorCode>-2146893812</ErrorCode><ErrorDetails xmlns:a="http://schemas.datacontract.org/2004/07/System.Collections.Generic"><KeyValuePairOfstringanyType><a:key>ApiExceptionSourceKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">Api/PostPipeline</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiSourceActivityKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema"/></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiExceptionOwnerKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">OwnershipNotFoundInExceptionOwnerSettings</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiOriginalExceptionKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">Microsoft.Crm.CrmException: ISV code reduced the open transaction count. Custom plug-ins should not catch exceptions from OrganizationService calls and continue processing.&#xD;
at Microsoft.Crm.BusinessEntities.ExecutionContext.ThrowIfInvalidPluginTransaction(Int32 countThreshold)&#xD;
at Microsoft.Crm.BusinessEntities.ExecutionContext.CommitTransaction(ProcessDependenciesOption option, FlushCacheOption flushOption)&#xD;
at Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context)&#xD;
at Microsoft.Crm.Extensibility.InternalMessageDispatcher.&lt;&gt;c__DisplayClass5_0.&lt;Execute&gt;b__0()&#xD;
at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action, IEnumerable`1 additionalCustomProperties)&#xD;
at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute(ILogger logger, XrmTelemetryActivityType activityType, Action action)&#xD;
at Microsoft.Crm.Extensibility.ExternalMessageDispatcher.ExecuteInternal(IInProcessOrganizationServiceFactory serviceFactory, IPlatformMessageDispatcherFactory dispatcherFactory, Guid callerRegardingObjectId, Int32 invocationSource, Version endpointVersion, OrganizationRequest request, OrganizationInternalRequest organizationInternalRequest)&#xD;
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.DispatchRequest(OrganizationRequest request, OrganizationInternalRequest organizationInternalRequest, SdkResponseDescription responseDescription, SdkPerformanceCounterContext sdkPerformanceCounterContext)&#xD;
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.ExecuteRequestRequestWithInstrumentation(OrganizationRequest request, OrganizationInternalRequest organizationInternalRequest)&#xD;
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.ExecuteRequestRequestWithInstrumentationOperation(OrganizationRequest request, OrganizationInternalRequest organizationInternalRequest)&#xD;
at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.&lt;&gt;c__DisplayClass22_0.&lt;ExecuteRequest&gt;b__0()</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiStepKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">00000000-0000-0000-0000-000000000000</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiDepthKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">2</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiActivityIdKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">07d7adb0-f7fd-42c8-8ade-a01a1fa437bd</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiPluginSolutionNameKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">System</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiStepSolutionNameKey</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">System</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiExceptionCategory</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">ClientError</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiExceptionMessageName</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">IsvTransactionCount</a:value></KeyValuePairOfstringanyType><KeyValuePairOfstringanyType><a:key>ApiExceptionHttpStatusCode</a:key><a:value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">400</a:value></KeyValuePairOfstringanyType></ErrorDetails><HelpLink>http://go.microsoft.com/fwlink/?LinkID=398563&amp;error=Microsoft.Crm.CrmException%3a8009000c&amp;client=platform</HelpLink><Message>ISV code reduced the open transaction count. Custom plug-ins should not catch exceptions from OrganizationService calls and continue processing.</Message><Timestamp>2023-01-05T21:23:47</Timestamp><ExceptionRetriable>false</ExceptionRetriable><ExceptionSource>SdkClientError</ExceptionSource><InnerFault i:nil="true"/><OriginalException>System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: ISV code reduced the open transaction count. Custom plug-ins should not catch exceptions from OrganizationService calls and continue processing. (Fault Detail is equal to Exception details: &#xD;
ErrorCode: 0x8009000C&#xD;
Message: ISV code reduced the open transaction count. Custom plug-ins should not catch exceptions from OrganizationService calls and continue processing.&#xD;
TimeStamp: 2023-01-05T21:23:47.8013818Z&#xD;
--&#xD;
).</OriginalException><TraceText i:nil="true"/></OrganizationServiceFault>
at Microsoft.CDSRuntime.SandboxWorker.SandboxCallbackService.<>c__DisplayClass16_1.<ExecuteStreamingCallBack>b__1(ExecuteRequest response)
at Microsoft.CDSRuntime.SandboxWorker.SandboxCallbackService.GrpcClientSendAndReceive(ExecuteResponse executeResponse, Func`2 isTerminalResponse)
at Microsoft.CDSRuntime.SandboxWorker.SandboxCallbackService.<>c__DisplayClass16_0.<ExecuteStreamingCallBack>b__0()
at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute(ILogger logger, EventId eventId, ActivityType activityType, Action action, IEnumerable`1 additionalCustomProperties)
at Microsoft.CDSRuntime.SandboxWorker.SandboxCallbackService.ExecuteStreamingCallBack(Func`2 callback, Func`2 isTerminalChunk, Func`2 HandleClientException)
at Microsoft.CDSRuntime.SandboxWorker.SandboxOrganizationService.Execute(String operation, ByteString serializedRequest, Assembly proxyTypes, Object traceSettings)
at Microsoft.CDSRuntime.SandboxWorker.SandboxOrganizationServiceWrapper.<>c__DisplayClass23_0.<ExecuteInternal>b__0()
at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)
at Microsoft.CDSRuntime.SandboxWorker.SandboxOrganizationServiceWrapper.ExecuteInternal(OrganizationRequest request)
at Microsoft.CDSRuntime.SandboxWorker.SandboxOrganizationServiceWrapper.CreateInternal(Entity entity)
at PluginProfiler.Plugins.ServiceWrappers.OrganizationServiceWrapper.Create(Entity entity)
at PluginProfiler.Plugins.ProfilerBase`1.Execute(T operationContext, ProfilerPluginContext context, ProfilerPluginReport report, Object inputParameter)
</TraceText>
</OrganizationServiceFault>
❗❗ This only occurs when the plugin attempts to execute an UpdateRequest. If I comment out that line of code the plugin runs to completion without error. And if I turn off profiling then the plugin always runs successfully. ❗❗
Hi Teams,
Somebody know how i can fix it?
i got the same error :'(
Hi Nick,
could you find a solution?
I got the same error message.
Best regards
The plugin code isn't creating an infinite loop. Filtering is applied on the Update step to ensure it won't trigger twice. Additionally, if we turn off profiling the plugin runs successfully without error. It's only when the profiler is wrapping the plugin execution that the error occurs.
This error usually occurs when the plugin you are trying to profile causes an infinite execution loop, meaning it is constantly retriggering itself, or when the profiled plugin triggers another plugin that throws an exception deeper down the execution pipeline.
The fact that it doesn't fail when you comment out the update line also supports this theory.
I would look in that direction.
Add some tracing to your code an see what gets written to the plugin trace log.
WarrenBelz
89
Most Valuable Professional
Michael E. Gernaey
72
Super User 2025 Season 1
mmbr1606
71
Super User 2025 Season 1