web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Plugin error

(1) ShareShare
ReportReport
Posted on by 155

I'm trying to debug a plugin by downloading the log file and attaching it to the plugin registration tool. I started the profiler and recreated the issue. I see that the error below : 

"Unexpected exception from plug-in (Execute): PluginProfiler.Plugins.ProfilerPlugin: System.Security.SecurityException: The data contract type 'Microsoft.Xrm.Sdk.OrganizationServiceFault' cannot be serialized in partial trust because the property 'ExceptionRetriable' does not have a public getter."

Any suggestions/Info on this?

Thank you.

*This post is locked for comments

I have the same question (0)
  • elebasi Profile Picture
    on at

    Same here

  • Michel Gueli Profile Picture
    982 on at

    Are you using the right Version of the pluginregistrationtool?

  • Community Member Profile Picture
    on at

    Based on the exception I assume, your plugin is registered in the Sandbox-Mode. In the Sandbox, not all operations are allowed. This is indicated by 'partial trust'. You can try to register your plugin in none-sandbox-mode and/or make your dll fully-trusted

  • Suresh_Satti Profile Picture
    205 on at

    I have run into the exact error as said in the initial post. In my case, i am trying to run a queryexpression. The same piece of code runs fine when i try using querybyattribute. Is there any suggestion that you would like to give. I am running the plugin in sandbox, i am not sure if my plugin dll is fully-trusted, please help with the steps that would help me make the dll fully trusted.

  • Community Member Profile Picture
    on at

    Can you paste the piece of code, that is causing the error, maybe it's easier to understand the error

  • Suresh_Satti Profile Picture
    205 on at

    The commented part runs fine i.e. querybyattribute, but the rest is for Queryexpression that is what is problematic.

                   //QueryByAttribute query = new QueryByAttribute { EntityName = "account", ColumnSet = new ColumnSet("name", "address1_city") };

                   // query.AddAttributeValue("statecode", 0);

                   //query.PageInfo.ReturnTotalRecordCount = true;

                   ConditionExpression condition1 = new ConditionExpression();

                   condition1.AttributeName = "address1_city";

                   condition1.Operator = ConditionOperator.Contains;

                   condition1.Values.Add("Red");

                   FilterExpression filter1 = new FilterExpression();

                   filter1.Conditions.Add(condition1);

                   QueryExpression query = new QueryExpression("account");

                   query.ColumnSet.AddColumns("name", "address1_city");

                   query.Criteria.AddFilter(filter1);

                   EntityCollection results = service.RetrieveMultiple(query);

  • Michel Gueli Profile Picture
    982 on at

    I've updated your code:

    var query = new QueryExpression("account");

    query.PageInfo.ReturnTotalRecordCount = true; //Why use this line????

    query.ColumnSet.AddColumn("name");

    query.ColumnSet.AddColumn("address1_city");

    query.Criteria.AddCondition("statecode", ConditionOperator.Equal, 0);

    query.Criteria.AddCondition("address1_city", ConditionOperator.Contains, "Red");

    EntityCollection results = service.RetrieveMultiple(query);

  • Suresh_Satti Profile Picture
    205 on at

    Still the same. See the below error.

    3302.error.png

  • Community Member Profile Picture
    on at

    Hi,

    try the following:

    public void Execute(IServiceProvider serviceProvider)
            {
                // Obtain the execution context from the service provider.
                Context =
                    (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
    
                // Get a reference to the Organization service.
                var factory =
                    (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                OrgService = factory.CreateOrganizationService(Context.UserId);
    
                var query =
                    new QueryExpression("account")
                    {
                        ColumnSet = new ColumnSet("name", "address1_city"),
                        Criteria =
                        {
                            Conditions =
                            {
                                new ConditionExpression("address1_city", ConditionOperator.Contains, "Red")
                            }
                        }
                    };
                var result = OrgService.RetrieveMultiple(query);
    
                foreach (var items in result.Entities)
                {
                    // do something
                }

    ......

    Set the breakpoint to the foreach, not the OrgService.Ret....

  • Suresh_Satti Profile Picture
    205 on at

    Sorry to say, it still dosent work. I continue to get the same error. Please see the below complete code that i ran.

    public class Class1 : IPlugin
    {
    public void Execute(IServiceProvider serviceProvider)
    {
    // Obtain the execution context from the service provider.
    var Context =
    (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

    // Get a reference to the Organization service.
    var factory =
    (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
    var OrgService = factory.CreateOrganizationService(Context.UserId);

    var query =
    new QueryExpression("account")
    {
    ColumnSet = new ColumnSet("name", "address1_city"),
    Criteria =
    {
    Conditions =
    {
    new ConditionExpression("address1_city", ConditionOperator.Contains, "Red")
    }
    }
    };
    var result = OrgService.RetrieveMultiple(query);

    foreach (var items in result.Entities)
    {
    items.Attributes["new_countofallrecords"] = result.Entities.Count.ToString();
    OrgService.Update(items);
    }
    }
    }
    }

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
JS-09031509-0 Profile Picture

JS-09031509-0 3

#3
Ciprian  P Profile Picture

Ciprian P 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans