This is the Exception that we will be looking at today:
The requested operation could not be performed because the CommerceEntity ‘CustomEntity’ does not map to a Commerce Server profile definition.
[FaultException`1: The requested operation could not be performed because the CommerceEntity 'TaxForm' does not map to a Commerce Server profile definition.]
Microsoft.Commerce.Providers.Utility.ProfileMetadata..ctor(CommerceEntityDefinition definition) +465
Microsoft.Commerce.Providers.Utility.ProfileMetadata.CreateProfileMetadata(MetadataCacheKey key, String modelName) +172
Microsoft.Commerce.Providers.Utility.<>c__DisplayClass5.<Get>b__4(MetadataCacheKey key) +54
Microsoft.Commerce.Application.Common.CachedFactory`2.GetOrCreate(TKey key, CreateInstance`2 factory) +435
Microsoft.Commerce.Providers.Utility.ProfileMetadata.Get(String modelName) +288
Microsoft.Commerce.Providers.Components.ProfileOperationSequenceComponent.get_Metadata() +89
Microsoft.Commerce.Providers.Components.ProfileOperationSequenceComponent.get_PrimaryKeyName() +40
Microsoft.Commerce.Providers.Components.RelatedProfileProcessorBase.ProcessQuery(CommerceQueryRelatedItem queryRelatedItem) +335
Microsoft.Commerce.Providers.Components.RelatedProfileOperationSequenceComponent.ExecuteQuery(CommerceQueryOperation queryOperation, OperationCacheDictionary operationCache, CommerceQueryOperationResponse response) +786
Microsoft.Commerce.Providers.Components.OperationSequenceComponent.Execute(CommerceOperation operation, OperationCacheDictionary operationCache, CommerceOperationResponse response) +348
Microsoft.Commerce.Providers.Components.ProfileOperationSequenceComponent.Execute(CommerceOperation operation, OperationCacheDictionary operationCache, CommerceOperationResponse response) +116
Microsoft.Commerce.Broker.OperationSequence.ExecuteComponentTree(List`1 executionTreeList, CommerceOperation operation, OperationCacheDictionary operationCache, CommerceOperationResponse response) +1040
Microsoft.Commerce.Broker.OperationSequence.Execute(CommerceOperation operation) +276
Microsoft.Commerce.Broker.MessageHandler.ProcessMessage(String messageHandlerName, CommerceOperation operation) +241
Microsoft.Commerce.Broker.OperationService.InternalProcessRequest(CommerceRequest request) +494
Microsoft.Commerce.Broker.OperationService.ProcessRequest(CommerceRequest request) +471
Microsoft.Commerce.Common.OperationServiceAgent.ProcessRequest(CommerceRequestContext requestContext, CommerceRequest request) +151
So I checked all of the standard things:
- Verified that ‘CustomEntity’ was setup correctly in Commerce Manager
- Ran a simple 2007 API based script to verify the relationship was setup correctly and that the ‘CustomEntity’ profile object was being returned correctly
- Checked the MetaDefinitions.xml and the ChannelConfiguration.config files to verify that they were indeed correct.
- Then I started scratching my head, I went over and over everything, and couldn’t figure out what was causing the problem.
Then I started using
Reflector, in Visual Studio integrated mode, I choose the following assemblies to debug.
- Microsoft.Commerce.Broker
- Microsoft.Commerce.Common
- Microsoft.Commerce.Contracts
- Microsoft.Commerce.Providers
Then we start the debugging process and the exception occurs, but with out any indication as to why. Then I start stepping through the code and I notice a line in the Provider assembly.
if (((target != null) && ProfileAssembly.Equals(target.get_CommerceServerAssembly(),
StringComparison.OrdinalIgnoreCase)) && ProfileTypeName.Equals(target.get_CommerceServerClass(),
StringComparison.OrdinalIgnoreCase))
{
return target;
}
What this code is doing is essentially, checking the data we provided in our MetaDefinitions.xml file to make sure that it matches the assembly information.
<!-- Custom Entity Start-->
<CommerceEntity name="CustomEntity">
<DisplayName value="Custom Entity" />
<EntityMappings >
<EntityMapping
csType="Microsoft.CommerceServer.Runtime.Profiles.Profile"
csAssembly="Microsoft.CommerceServer.Runtime, Version=6.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
csDefinitionName="CustomEntity"
csArea="Profiles">
<PropertyMappings>
<PropertyMapping property="Id" csProperty="GeneralInfo.u_Custom_Entity_id" />
<PropertyMapping property="FormName" csProperty="GeneralInfo.b_Custom_Entity_image" />
<PropertyMapping property="DateCreated" csProperty="GeneralInfo.dt_date_created" />
<PropertyMapping property="FormImage" csProperty="GeneralInfo.u_Custom_Entity_name"/>
</PropertyMappings>
</EntityMapping>
</EntityMappings>
</CommerceEntity>
<!-- Custom Entity End—>
Do you see the problem? Well at first neither did I, and for that matter at second or third…. Look closely at this line
csAssembly=”Microsoft.CommerceServer.Runtime, Version=6.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″
Is should actually read:
csAssembly=”Microsoft.CommerceServer.Runtime, Version=6.
0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″
Once that simple typo was corrected, the whole process seemed to come to life.