Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

CRM 2013 - How to debug a Plugin in production

Posted on by Microsoft Employee

I have a plugin that was tested and working in preprod (test) but not working in the production environment.

When I tried to debug the plugin using the registration tool I get a parsing error for the errorDetails.txt generated from the production Business Process error. The same managed solution is deployed to preprod and production. Can someone tell me why this plugin that is working in Preprod is not working in Production. Ans also how can I debug the plugin with the Production error. Thanks.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM 2013 - How to debug a Plugin in production

    The difference is the Managed Plugin profiler solution in default solution of Production and not in DEV. I am trying to remove each dependent component but I cant delete the components under Entity relationship.

    eg:

    When  I tried to remove the Plugin profiler solution from registration tool I am getting this error:

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: This solution cannot be uninstalled because the 'EntityRelationship' with id '76a874f0-5f60-e711-80fe-001dd8b71e34(mbs_systemuser_mbs_pluginprofile)'  is required by the 'BaseCMSSolution' solution. Uninstall the BaseCMSSolution solution and try again.
    Detail: <OrganizationServiceFault xmlns="schemas.microsoft.com/.../Contracts" xmlns:i="www.w3.org/.../XMLSchema-instance">
      <ErrorCode>-2147160032</ErrorCode>
      <ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic">
        <KeyValuePairOfstringanyType>
          <a:key>0</a:key>
          <a:value i:type="b:string" xmlns:b="www.w3.org/.../XMLSchema">EntityRelationship</a:value>
        </KeyValuePairOfstringanyType>
        <KeyValuePairOfstringanyType>
          <a:key>1</a:key>
          <a:value i:type="b:string" xmlns:b="www.w3.org/.../XMLSchema">76a874f0-5f60-e711-80fe-001dd8b71e34(mbs_systemuser_mbs_pluginprofile)</a:value>
        </KeyValuePairOfstringanyType>
        <KeyValuePairOfstringanyType>
          <a:key>2</a:key>
          <a:value i:type="b:string" xmlns:b="www.w3.org/.../XMLSchema">BaseCMSSolution</a:value>
        </KeyValuePairOfstringanyType>
      </ErrorDetails>
      <Message>This solution cannot be uninstalled because the 'EntityRelationship' with id '76a874f0-5f60-e711-80fe-001dd8b71e34(mbs_systemuser_mbs_pluginprofile)'  is required by the 'BaseCMSSolution' solution. Uninstall the BaseCMSSolution solution and try again.</Message>
      <Timestamp>2017-08-04T07:30:49.723326Z</Timestamp>
      <InnerFault>
        <ErrorCode>-2147160032</ErrorCode>
        <ErrorDetails xmlns:a="schemas.datacontract.org/.../System.Collections.Generic" />
        <Message>This solution cannot be uninstalled because the 'EntityRelationship' with id '76a874f0-5f60-e711-80fe-001dd8b71e34(mbs_systemuser_mbs_pluginprofile)'  is required by the 'BaseCMSSolution' solution. Uninstall the BaseCMSSolution solution and try again.</Message>
        <Timestamp>2017-08-04T07:30:49.723326Z</Timestamp>
        <InnerFault i:nil="true" />
        <TraceText i:nil="true" />
      </InnerFault>
      <TraceText i:nil="true" />
    </OrganizationServiceFault>

    Server stack trace:
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]:
       at PluginProfiler.Library.ProfilerManagementUtility.UninstallProfiler(CrmServiceClient service)
       at Microsoft.Crm.Tools.Libraries.OrganizationHelper.UninstallProfiler(CrmOrganization org)
       at Microsoft.Crm.Tools.PluginRegistration.OrganizationControlViewModel.<>c__DisplayClass27.<InstallProfiler_Clicked>b__1b(Object o, DoWorkEventArgs e)

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: CRM 2013 - How to debug a Plugin in production

    Chrys,

    I looked at your exception and could not really see anything that would tell me where your problem is.

    Not sure if this is possible for you to do, and not the best approach. Usually I have more than just dev and production servers for these kind of scenarios so that it can be replicated to another server. If you have a test/stage environment, maybe you can get this error in that environment as well. What are the differences between your stage (preprod) and prod?

    You can also install Visual Studio Remote debugger on server, and attach to w3wp process from your development machine and place breakpoint in your code..

    Make sure not to do this during business hours, as this will affect all users connecting to the server.

    Hope this will help you in some way, or maybe someone else has a better solution :)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM 2013 - How to debug a Plugin in production

    Hi Aric,

    Thanks for response.

    In our DEV or Production environments (CRM 2013 On-Premise), we don't have the Plug-in and custom workflow activity tracing option under System settings (may be it is a 365 feature). I can see only the application mode option.

    In my code I have the tracing enabled and I have been debugging in local without any problem and I don't get any errors in the plugin or when importing. I get the error only in Production and during the Update event that triggers the step. Thanks in advance.

    // Extract the tracing service for use in debugging sandboxed plug-ins.

    ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

    2677.plugin.PNG

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: CRM 2013 - How to debug a Plugin in production

    Hi Prateek,

    Thanks for the prompt response. I have debugged the plugin connecting to my local previously and I did not have any issue. But when I connect to production and start profiling, the business process error I am getting from production event is not like the error in your step 3 (similar to what I have been getting when debugging locally).

    Am I missing anything or any version issue with the Plugin profiler?

    Thanks.

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: CRM 2013 - How to debug a Plugin in production

    If you use Tracing in your plugin, and you enable exceptions in your System Settings you should be able to see and get information within the plugin. Then you should be able to see the trace log in the Plugin Trace Log

    Within the plugin:

           protected void ExecutePostAccountCreate(LocalPluginContext localContext)

           {

               if (localContext == null)

               {

                   throw new ArgumentNullException("localContext");

               }

               // ProcessCustomerRelationship(localContext);

               string entityName = localContext.PluginExecutionContext.PrimaryEntityName;

               Guid entityId = localContext.PluginExecutionContext.PrimaryEntityId;

               ITracingService tracingService = localContext.TracingService;

               tracingService.Trace("Entered {0} Plugin Method", "ExecutePostACcountCreate");

               CreateAccountLogic(entityName, entityId);

           }

    Enter tracing wherever you need in your AccountLogic function to get the information that you need back:

    void CreateAccountLog(string entityName, Guid entityId)

    {

      tracingService.Trace("Entity Name is {0} ", entityName);

    }

    In System Settings, Go to Customizations tab, and under Plugin and custom workflow activity tracing, select Exception

    plugintracing.png

    Run you process again, and go to Plugin Trace Log under Settings. You should be able to see the errors that you encountered there...

    Hope this helps.

  • Suggested answer
    prt33k Profile Picture
    prt33k 6,907 on at
    RE: CRM 2013 - How to debug a Plugin in production

    Hi Chrys,

    The step for debugging in sandbox and prod environemt are same. Refere here for detail on how to debug

    http://himbap.com/blog/?p=2469

    However you can try enabling Plugin Trace Logs and if you code was having proper tracing then that would be able to help you to get to the issue.

    Thanks,

    Prateek

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans