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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Verified answer
    David Jennaway Profile Picture
    14,065 on at

    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

  • Dhaval mistry Profile Picture
    810 on at

    after removing this line, its start working

    orgService.EnableProxyTypes();

  • PZ-Mitchell Profile Picture
    10 on at

    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);

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans