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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Adding OrganizationProxyType - setProxyType (Assembly.getExecutingAssembly()) to plugin issue

(0) ShareShare
ReportReport
Posted on by 265

So this is a bit of a strange issue since it happens sporadically and I believe doing the above. i.e.,

setting ProxyType on the OrganizationServiceProxy to add behaviour (Assembly.getExecutingAssembly()) is done so that when the plugin runs it picks up the executing assembly and does not throw the 

"A proxy type with the name <entityname> has been defined by multiple-types"

On reading/researching some of the google links. This is accomplished in a console app since the credentials are available. username/password.

How would this be accomplished in a plugin ? The WhoAmI request would provide userID, Domain/Org but not password. So how do we set up the credentials part required to create an instance of the Organization Service Proxy in the plugin ?

Spent a few hours on this.

Any help/guidance is appreciated.

Thank you.

*This post is locked for comments

I have the same question (0)
  • SCV Profile Picture
    1,004 on at

    You don't need the password to create an instance of the Organisation Service. Plugin execution context has it. Try following code in your plugin.

    public void Execute(IServiceProvider serviceProvider)
    {
     IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
     IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
     IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);
    }


  • surajtalreja Profile Picture
    265 on at

    Hi Sachin

    Not the OrganizationService. We need the OrganizationServiceProxy to be able to set the property telling the CRM to use the currently executing Assembly.

    This error when the plugin runs: ""A proxy type with the name <entityname> has been defined by multiple-types"

    comes because a particular proxy class might be exisiting in several plugin assembly and we need a way to tell CRM to use the proxy from the currently executing assembly.

    In a Windows App this might be easier to accomplish since we can get the credentials from the config file.

    Not sure how we would do this in a plugin.

    Adding some pseudo code that I have gathered through google research to aid in understanding.

    //localContext.CrmContext.

                   //Basically we need to do something like -

                   //create an OrganizationProxy class where we can say please use executing Assembly for proxy type

                   //so something like

                   //OrgProxy ogProx = OrganizationService.ToOrgServiceProxy(CrmConnection)

                   //CrmConnection needs uri, other parameters...

                   //use Service classes to get uri

                   //Service URls - get or set primary end point

                   //msdn.microsoft.com/.../microsoft.xrm.sdk.client.serviceurls.aspx

                   //stackoverflow.com/.../a-proxy-type-with-the-name-account-has-been-defined-by-another-assembly

                   //public OrganizationServiceProxy(Uri uri, Uri homeRealmUri, ClientCredentials clientCredentials, ClientCredentials deviceCredentials);

                   //var orgProxy = new OrganizationServiceProxy();

                   //Assembly.GetExecutingAssembly()

    Hope that helps ...

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans