Multiple Early Bound Files in Web Service

若如初见. 提交于 2019-12-10 21:04:51

问题


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:

  1. Create separate Assemblies.
  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!