[MPOS Technical Development]- Refactoring/Renaming of a CRT Entity in Extensions

If you decide to refactor or rename a Commerce Runtime (CRT) entity (lets say OldEntityName to NewEntityName) inheriting from CommerceEntity, one issue that I have faced is in Retail Server extension assembly the build fails with errors due to the RetailProxy classes relying on the definition of your old entity name.

Example of the error messages that you would see in this scenario are as follows-

Could not load type OldEntityName from assembly… and the command ‘bin\CommerceProxyGenerator.exe’ ..

Retail Proxy Error

The solution to this issue is a little tricky one. You need to compile the CRT data dlls keeping the OldEntityName in the References folder.

You need to then comment any reference to NewEntityName in the Retail Server Extension assembly. Then do a clean and a build of the solution.

If this succeeds with no errors, you can now go ahead to uncomment all references to NewEntityName in the Retail Server Extension assembly.

<Update>This article is based on 7.1 Retail SDK </Update>

-Hitesh Manglani






Custom error messages in MPOS

This post is for describing how we can show custom error messages in MPOS.

MPOS standard error handlers require that the strings to be shown as error messages are entered in the following format within the resources.json file (en-US).

“string_55001” : “This is a custom error.”,

Within MPOS we could use the following snippet to display any custom error messages

let displayMessageActivity: Commerce.Activities.DisplayMessageActivity = new Commerce.Activities.DisplayMessageActivity({
title: ‘Custom Error’,
message: Commerce.ViewModelAdapter.getResourceString(“string_55001“)
displayMessageActivity.execute().done(() => {
// code to run on successful display of the error dialog
}).fail(() => {
// code to run on failure in displaying the error dialog

If however the error condition is met in the Commerce Run Time (CRT) you need to show the error message in MPOS, you can leverage the CommerceRunTimeException

throw new CommerceException(“string_55047”, “CUSTOM ERROR MESSAGE”);


One possibility is that the error messages could be coming from a third party application. On a recent integration I received a list of predefined error codes with error messages from the application.I then defined an enum in the CRT which had the values as this status codes and names as the error messages




I defined a corresponding Enum in the CRT

public enum AppError




After deserializing the response I checked the ReturnStatus code from the application and used an offset (50050) to throw the correct error message from the resources.json file

if (Enum.IsDefined(typeof(AppError), res.ReturnStatus))
AppError err = (AppError)res.ReturnStatus;
throw new CommerceException(“string_” + (50050 + res.ReturnStatus) , err.ToString().Replace(“_”, ” “));

<Update>One thing you need to be aware is that the Error Status Code and Error Messages returned by the application should be constant. Any changes would mean that the MPOS package will need to be regenerated and redeployed.

I got following suggestion from my Mentor Mani (from Microsoft) for displaying the custom error messages- you can set custom properties in the response (CRT) and then parse the response in MPOS and show your message, you can also use extension properties and then parse it in MPOS. With this approach no need to define the error messages in resources.json.


Hope this helps

-Hitesh Manglani