问题
I have a WCF service with 3 different endpoints that need to use different Dynamics CRM early bound class files. I have them in separate namespaces, and have removed: [assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute()] I can't seem to figure out how to specify which early bound file to use to when enabling proxy types. I am trying to avoid having each early bound file in a separate project. The files share some similar entities, but most importantly there are unique fields and entities that do not exist in the development organizations for the respective endpoints (endpoint 1 has entities that do not exist in endpoint 2).
回答1:
You'll need to have the ProxyTypesAssemblyAttribute defined in at least one file. It doesn't matter what file actually, since it is an assembly attribute, not a class attribute. You'll need to make sure that you don't attempt to use a type for an IOrganizationService call, that doesn't exist in that org.
Update 1
My understanding of the way the ProxyTypesAssemblyAttribute works was wrong. Apparently you can't have more than one class in the same assembly with the same Microsoft.Xrm.Sdk.Client.EntityLogicalNameAttribute(string) attribute (The string value has to be unique).
You have two possible solutions:
- Create separate Assemblies.
- Use the same namespace for both but don't duplicate classes by creating a class per entity for each CRM Org (This is where the https://xrmearlyboundgenerator.codeplex.com/ becomes very helpful). Any entities that exist in both, you'll have to either
- Manually merge any differences (And when you're calling it, you'll have to know what is valid and what isn't valid for each Org! i.e. If Org 1's Contact entity has a ShirtSize field and Org 2 doesn't, you can't populate that attribute and attempt to insert into Org 2),
- Use the file from one Org, and delete the other.
The second possible solution would work, but I don't think it's viable.
来源:https://stackoverflow.com/questions/24785241/multiple-early-bound-files-in-web-service