Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Error A proxy type with the name <<Entity Name>> has been defined by another assembly

Posted on by 810

Hi,

I am facing below issue. 

scenario, we have multi-tenant environment in our organization, lets assume ORG-A, ORG-B & ORG-C. All are independent environment no direct relationship.

Requirement: I needs to pull data from ORG-B and show it on ORG-A on web resource. I need to connect ORG-B using service account. 

Design: I created one custom action on ORG-A and register one post sync step. i am creating new connection with ORG-B CRM and try to pull the record from ORG-B and return back to ORG-A form as XML format. 

Issue: while creating connection from ORG-A plug-in to ORG-B using below code and try to pull the record using LINQ. I got below error message. 

A proxy type with the name <<ORG-C entityName>> has been defined by another assembly. Current type: <<ORG - C Utility class reference >>, <<ORG-C Workflow assembly>>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a894a5e902227c3d, Existing type: <<ORG - C Utility class reference >>, <<ORG - C Utility class reference >>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a1c7072af06fb43c
Parameter name: <<ORG-C entityName>>

Below is the code to create Org Service instance to connect ORG-B

private IOrganizationService GetUSDCRMService()
        {
ClientCredentials clientCredentials = new ClientCredentials();
           clientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("serviceAcc", "password", "domain"); 
            string orgUrl = GetOrgUrl() + "XRMServices/2011/Organization.svc";
            var orgService = new OrganizationServiceProxy(new Uri(orgUrl), null, clientCredentials, null);
            orgService.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior(Assembly.GetExecutingAssembly()));
            
            
            orgService.EnableProxyTypes();
            orgService.Timeout = new TimeSpan(0, 6, 0);
            return (IOrganizationService)orgService;
 }

There is no relation with ORG-A & ORG-C as well. 
Please suggest where did I made mistake 

*This post is locked for comments

  • PZ-Mitchell Profile Picture
    PZ-Mitchell 10 on at
    RE: Error A proxy type with the name <<Entity Name>> has been defined by another assembly

    Issue also occurs on .Net6 when using OpenAPI and the new Dataverse Client (ServiceClient). Only fix I've found is cloning the setted up ServiceClient with the Assembly reference:

    ServiceClient serviceClient = new ServiceClient(new Uri(Environment.GetEnvironmentVariable("DataverseUrl")), Environment.GetEnvironmentVariable("DataverseClientId"), Environment.GetEnvironmentVariable("DataverseSecret"), false, log);
    
    ServiceClient service = serviceClient.Clone(Assembly.GetExecutingAssembly(), log);

  • Dhaval mistry Profile Picture
    Dhaval mistry 810 on at
    RE: Error A proxy type with the name <<Entity Name>> has been defined by another assembly

    after removing this line, its start working

    orgService.EnableProxyTypes();

  • Verified answer
    David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Error A proxy type with the name <<Entity Name>> has been defined by another assembly

    Based on the error, it may be that if you have code that connects to multiple organisations, then there could be collisions on the ProxyTypes.

    You only need the ProxyTypes if you use early bound classes, so I'd suggest you use late bound classes instead, and don't call EnableProxyTypes

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans