Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

a proxy type with the name account has been defined by another assembly

  • We have 2 orgs running in our on-premise crm 2011 system.
  • We have generated early bound classes for both orgs.
  • One of our plugins is throwing the "a proxy type with the name account has been defined by another assembly" error when deactivating an account.
  • That plugin only references one of the early bound dll's.

How do I get the CRM system to respect the namespace of these references.
I've tried the few items that show up from Google and none are working.

Since you can reproduce this with 2 vanilla orgs I would imaging there is something OUTSIDE the code layer we can do without having to go back and refactor a bunch of code for the 2 orgs.

Thanks,
Jon

like image 905
user1231231412 Avatar asked Feb 02 '23 10:02

user1231231412


1 Answers

The problem is actually with WCF attempting to deserialize the server response and not being able to identify the correct type. The best method to sort this issue is to pass in the current assembly using Assembly.GetExecutingAssembly() to the ProxyTypesBehavior() while creating the proxy like so.

using (serviceProxy = new OrganizationServiceProxy(config.OrganizationUri,
                config.HomeRealmUri,
                config.Credentials,
                config.DeviceCredentials))
        {
            // This statement is required to enable early-bound type support.
            serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior(Assembly.GetExecutingAssembly()));
        }
like image 65
Umair Ishaq Avatar answered Feb 05 '23 03:02

Umair Ishaq