Invalid cast in Commerce Manager after update from 11.2.5 to 11.8.5

Vote:
 

Hi all,

After upgrading from Commerce 11.2.5 to 11.8.5, which should not contain any breaking change, we get the following error in Commerce Manager when trying to create a return. Anyone seen this error? Is this an undocumented breaking change?

[InvalidCastException: Unable to cast object of type 'EPiServer.Commerce.Order.Internal.InMemoryShipment' to type 'Mediachase.Commerce.Orders.Shipment'.]
EPiServer.Commerce.Order.Calculator.DefaultShippingCalculator.GetShippingRate(IShipment shipment, ShippingMethodRow row, IMarket market) +282
EPiServer.Commerce.Order.Calculator.DefaultShippingCalculator.CalculateShippingCost(IShipment shipment, IMarket market, Currency currency) +575
EPiServer.Commerce.Order.Calculator.DefaultShippingCalculator.GetDiscountedShippingAmount(IShipment shipment, IMarket market, Currency currency) +388
EPiServer.Commerce.Order.Calculator.DefaultTaxCalculator.CalculateShippingTaxTotal(IShipment shipment, IMarket market, Currency currency, Func`3 getShippingTotalFunc, Func`3 getDiscountedPriceFunc, Boolean isReturn) +311
EPiServer.Commerce.Order.Calculator.DefaultTaxCalculator.CalculateShippingTaxTotal(IShipment shipment, IMarket market, Currency currency) +259
EPiServer.Commerce.Order.Calculator.DefaultTaxCalculator.GetShippingTaxTotal(IShipment shipment, IMarket market, Currency currency) +367
EPiServer.Commerce.Order.Calculator.<>c__DisplayClass7_0.<GetTotalForReturns>b__1(IShipment shipment) +157
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +233
System.Linq.Enumerable.Sum(IEnumerable`1 source) +98
EPiServer.Commerce.Order.Calculator.DefaultReturnPurchaseOrderCalculator.GetTotalForReturns(IPurchaseOrder order) +788
EPiServer.Commerce.Order.Calculator.DefaultReturnPurchaseOrderCalculator.CalculateReturnTotal(IPurchaseOrder purchaseOrder, IReturnOrderForm currentReturnForm, Boolean isCompletingReturnForm) +338
Mediachase.Commerce.Manager.Apps.Order.Modules.OrderCreateReturn.CalculateReturnTotal() +147
Mediachase.Commerce.Manager.Apps.Order.Modules.OrderCreateReturn.Page_Load(Object sender, EventArgs e) +1241
System.Web.UI.Control.OnLoad(EventArgs e) +106
System.Web.UI.Control.LoadRecursive() +68
System.Web.UI.Control.LoadRecursive() +162
System.Web.UI.Control.LoadRecursive() +162
System.Web.UI.Control.LoadRecursive() +162
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3785

#201002
Feb 01, 2019 12:15
Vote:
 

It sounds like your shipment has the wrong shipping gateway/plugin attached. It should have been a class that implements IShippingPlugin, but it only implements IShippingGateway 

#201003
Feb 01, 2019 12:22
Vote:
 

Hi Quan. When did this change? It seems it stopped working for us when going from 11.2.5 to 11.8.5.

#201004
Feb 01, 2019 12:50
Vote:
 

I can't recall any change related to this. Which is the shipping method attached to this shipment. What does the implementation of that shipping method look like? 

#201005
Feb 01, 2019 12:55
Vote:
 

It is a custom gateway which implements IShippingGateway. The invalid cast occurs in GetRate() since it expects a Shipment but gets an IShipment.

I'll try to change the implementation but one thing occured to me. We rely on data from the orderform and ordergroup which we get from LineItem.Parent and LineItem.Parent.Parent. I don't see any replacement for that in IShipment. How can we resolve which OrderForm an IShipment belongs to?

#201006
Feb 01, 2019 13:15
Vote:
 

Hmm, what does your CM Configs\ecf.app.config look like 

#201007
Feb 01, 2019 13:30
Vote:
 

<?xml version="1.0" encoding="utf-8"?>
<Application defaultApplicationName="xxxxx.CommerceAdmin">
<Roles>
<add name="AdminRole" value="Admins"/>
<add name="ManagerUserRole" value="Management Users"/>
<add name="EveryoneRole" value="Everyone"/>
<add name="RegisteredRole" value="Registered"/>
</Roles>
<Connection connectionStringName="EcfSqlConnection"/>
<Cache enabled="true" appTimeout="0:0:10"/>
<Languages>
<add key="en-us" value="English"/>
<add key="da-DK" value="Danish"/>
<add key="sv-SE" value="Svenska"/>
<add key="fi-FI" value="Suomi"/>
<add key="nl-NL" value="Netherlands"/>
<add key="nb-NO" value="Norsk"/>
<add key="fr-FR" value="French"/>
</Languages>
<Features>
<add feature="WorkflowsVNext" state="Disabled" type="Mediachase.Commerce.Core.Features.WorkflowsVNext, Mediachase.Commerce"/>
</Features>
</Application>

#201008
Feb 01, 2019 13:32
Vote:
 

Shouldn't it be Enabled for WorkflowsVNext

#201009
Feb 01, 2019 13:34
Vote:
 

We're still on the old promotion system.

#201011
Feb 01, 2019 13:40
Vote:
 

Please reach out for developer support service, and we can take it from there 

#201012
Feb 01, 2019 14:01
Vote:
 

HI Quan

Did you get to the bottom of this. We seem to ebe getting the same error when trying to do a return in commerce manager.

Regards

Sandeep

#247409
Jan 21, 2021 17:26
Vote:
 

Unfortunately no - or if we did - I forget it now. Please reach out to developer support service 

#247444
Jan 22, 2021 9:04
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.