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

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Cannot explicitly call operator or accessor

(1) ShareShare
ReportReport
Posted on by 155

Because of lost source control, I must decompile a plugin to edit it.

I downloaded the plugin with Assembly Recovery tool.

I decompiled and exported the plugin with dotpeak.

In Visual Studio 2019 I have added the Microsoft.crmSdk.XrmTooling.CoreAssembly v6.1.1 with nuget.

After following all the above steps I am left with 99+ “cannot explicitly call operator or accessor” errors in the plugin.

Here are two examples:

1. IOrganizationService organizationService = ((IOrganizationServiceFactory) serviceProvider.GetService(typeof (IOrganizationServiceFactory))).CreateOrganizationService(new Guid?(((IExecutionContext) service).get_UserId()));

Error CS0571 'IExecutionContext.UserId.get': cannot explicitly call operator or accessor

 2. entityReference2.set_LogicalName("product");

Error CS0571 'EntityReference.LogicalName.set': cannot explicitly call operator or accessor

Why are there so many errors? Is there a step that I am missing?

What would be the best way to correct the 99+ errors

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Cannot explicitly call operator or accessor

    Hello,

    Try to use following code instead:

    IOrganizationService organizationService = ((IOrganizationServiceFactory) serviceProvider.GetService(typeof (IOrganizationServiceFactory))).CreateOrganizationService(context.UserId);

    entityReference2.LogicalName = "product";

  • Verified answer
    David Jennaway Profile Picture
    14,065 on at
    RE: Cannot explicitly call operator or accessor

    The errors can broadly be split into 2.types:

    1. Those for the standard code to get the IOrganizationService instance, which you can fix with a general find & replace (see below)
    2. Ones where the generated code tries to call a method instead of reading/setting a property - e.g. entityReference2.set_LogicalName("product") should be entityReference2.LogicalName = "product". Here the fix is pretty similar for each line, but a Find & Replace would handle all the syntax changes needed

    In both cases these are due to the decompiler expecting methods that MS haven't provided. Another decompiler may do a better job, but it may be quicker to make the changes manually

    For item 1, where you have:

    IOrganizationService organizationService = ((IOrganizationServiceFactory) serviceProvider.GetService(typeof (IOrganizationServiceFactory))).CreateOrganizationService(new Guid?(((IExecutionContext) service).get_UserId()));

    You should be able to do a general replace with the following:

                IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
                IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 130

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 118 Super User 2025 Season 2

#3
Erin Lubben Profile Picture

Erin Lubben 57

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans