Avontus 2016 - GetStockingLocation / GetOrganization

I have a problem with API code that was working fine and now it appears broken with the new update to Avontus 2016.

These are the 2 API calls:

StockingLocation sl = null;
sl = StockingLocation.GetStockingLocation(Guid.Parse (StockingLocationID), true);

job.HistoryRateProfile = sl.ParentBranchOrLaydown.Number;

I have managed to work around #1 by using the StockingLocationCollection object:

StockingLocationCollection slc = null;
Guid[] sls = new Guid[1];

sls [0] = Guid.Parse (StockingLocationID);
slc = StockingLocationCollection.GetStockingLocationCollection (sls);

StockingLocation sl = null;
sl = slc [0];

But here is the stack track of the error when trying to get the “ParentBranchOrLaydown” property from the StockingLocation object, which was a similar issue when using the “GetStockingLocation” method:

Avontus.Core.DataPortalException: DataPortal.Fetch failed (DataPortal.Fetch failed (Method not found: ‘!!0[] System.Array.Empty()’.)) —> Avontus.Core.Reflection.CallMethodException: DataPortal_Fetch method call failed —> Avontus.Core.DataPortalException: DataPortal.Fetch failed (Method not found: ‘!!0[] System.Array.Empty()’.) —> Avontus.Core.Reflection.CallMethodException: DataPortal_Fetch method call failed —> System.MissingMethodException: Method not found: ‘!!0[] System.Array.Empty()’. at Avontus.Rental.Library.ExistsGeneric.DataPortal_Fetch(Criteria criteria) at dm(Object , Object[] ) at Avontus.Core.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) — End of inner exception stack trace — at Avontus.Core.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) at Avontus.Core.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) — End of inner exception stack trace — at Avontus.Core.DataPortal.Fetch(Type objectType, Object criteria) at Avontus.Core.DataPortal.Fetch[T](Object criteria) at Avontus.Rental.Library.ExistsGeneric.JobSiteHasInvoices(Guid stockingLocationID) at Avontus.Rental.Library.StockingLocation.LoadHasBilling() at Avontus.Rental.Library.StockingLocation.Fetch(SafeDataReader dr, Boolean prefetchChildren) at Avontus.Rental.Library.StockingLocation.DataPortal_Fetch(RootCriteria criteria) at dm(Object , Object[] ) at Avontus.Core.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) — End of inner exception stack trace — at Avontus.Core.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) at Avontus.Core.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) — End of inner exception stack trace — at Avontus.Core.DataPortal.Fetch(Type objectType, Object criteria) at Avontus.Core.DataPortal.Fetch[T](Object criteria) at Avontus.Rental.Library.StockingLocation.GetOrganization(Guid StockingLocationID, Boolean prefetchChildren) at Avontus.Rental.Library.StockingLocation.get_ParentBranchOrLaydown() at Avontus.Rental.Wrapper.ShipToService.GetJobSite(String StockingLocationID) — End of inner exception stack trace —

Please advise

Hello and Happy New Year!

We don’t have any breaking changes in the latest release. For the first one In looking at the stack trace for the first one I suspect you’re passing in an empty Guid? Try changing it to this:

slID = Guid.Parse(StockingLocationID);
if (slID != Guid.Empty)
{
// Load
}

For the second one the exception is stating that your array is empty (‘System.Array.Empty()’. If you check for this you’ll see this also.

Happy new year to you too!

The GUID is not empty since there is check for that before calling those functions. If you notice on my “fix”, I am using that same GUID to get the information from the StockingLocationCollection.

sls [0] = Guid.Parse (StockingLocationID);
slc = StockingLocationCollection.GetStockingLocationCollection (sls);

As per the empty array, this happens on an internal call. If you go all the way down on the stack track, the “original” caller function is “GetOrganization” which in turn calls the “Fetch” function. There is no way for me to check for an empty array since the call I am trying to do is this:

StockingLocation branch;
branch = sl.ParentBranchOrLaydown;

Internally, the ParentBranchOrLaydown property is defined as seen below. The class call should have handled all that internally and return null in case there is no parent branch, however it throws the error I showed above.

Again, this used to work without any issues in Avontus 2015.

public StockingLocation ParentBranchOrLaydown
{
get
{
TradingPartner tradingPartner;
if (this._parentBranchOrLaydown == null)
{
tradingPartner = TradingPartner.GetTradingPartner (base.ParentTradingPartnerID);
goto IL_3A;
}
goto IL_42;
IL_2E:
tradingPartner = TradingPartner.GetTradingPartner (tradingPartner.ParentTradingPartnerID);
IL_3A:
if (tradingPartner.ParentTradingPartner != null)
{
if (tradingPartner.TradingPartnerType == PartnerTypes.BranchOffice || tradingPartner.TradingPartnerType == PartnerTypes.LaydownYard)
{
return StockingLocation.GetOrganization (tradingPartner.StockingLocationID, true);
}
goto IL_2E;
}
IL_42:
if (3 != 0)
{
return null;
}
goto IL_2E;
}
}

I’m not sure how it was working before because the code of the property in question has not changed in almost 3 years (according to our version control system).

Perhaps you are attempting access the ParentBranchOrLaydown property on a TradingPartner that does not have a parent TradingPartner? From the look of it, a crash like the one you’re getting will happen in that case and I agree it shouild return null and not throw an exception. I’ve checked in a fix which will be a part of the next major release.

In the mean time, as a work-around, you can check if the property ParentTradingPartnerID == Guid.Empty and if so, do not access ParentBranchOrLaydown. The same also applies to the ParentBranchOrLaydownOrStagingArea property.

Please try the workaround and make sure to update this thread with the result. Thanks.

To clarify this jobsite does in fact have a parent branch.

I tried your suggestion:

if (sl.ParentTradingPartnerID != Guid.Empty)
job.HistoryRateProfile = sl.ParentBranchOrLaydown.Number;

Same problem:

System.Web.Services.Protocols.SoapException: Server was unable to process request. —> Avontus.Core.DataPortalException: DataPortal.Fetch failed (DataPortal.Fetch failed (Method not found: ‘!!0[] System.Array.Empty()’.)) —> Avontus.Core.Reflection.CallMethodException: DataPortal_Fetch method call failed —> Avontus.Core.DataPortalException: DataPortal.Fetch failed (Method not found: ‘!!0[] System.Array.Empty()’.) —> Avontus.Core.Reflection.CallMethodException: DataPortal_Fetch method call failed —> System.MissingMethodException: Method not found: ‘!!0[] System.Array.Empty()’. at Avontus.Rental.Library.ExistsGeneric.DataPortal_Fetch(Criteria criteria) at dm(Object , Object[] ) at Avontus.Core.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) — End of inner exception stack trace — at Avontus.Core.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) at Avontus.Core.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) — End of inner exception stack trace — at Avontus.Core.DataPortal.Fetch(Type objectType, Object criteria) at Avontus.Core.DataPortal.Fetch[T](Object criteria) at Avontus.Rental.Library.ExistsGeneric.JobSiteHasInvoices(Guid stockingLocationID) at Avontus.Rental.Library.StockingLocation.LoadHasBilling() at Avontus.Rental.Library.StockingLocation.Fetch(SafeDataReader dr, Boolean prefetchChildren) at Avontus.Rental.Library.StockingLocation.DataPortal_Fetch(RootCriteria criteria) at dm(Object , Object[] ) at Avontus.Core.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) — End of inner exception stack trace — at Avontus.Core.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) at Avontus.Core.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) — End of inner exception stack trace — at Avontus.Core.DataPortal.Fetch(Type objectType, Object criteria) at Avontus.Core.DataPortal.Fetch[T](Object criteria) at Avontus.Rental.Library.StockingLocation.GetOrganization(Guid StockingLocationID, Boolean prefetchChildren) at Avontus.Rental.Library.StockingLocation.get_ParentBranchOrLaydown() at Avontus.Rental.Wrapper.ShipToService.GetJobSite(String StockingLocationID) — End of inner exception stack trace —

I also found this problem on the Shipment object when trying to access the “PreReturnLabelText” property.

so.PreReturnLabelText = rental.PreReturnLabelText;

Error:

System.Web.Services.Protocols.SoapException: Server was unable to process request. —> Avontus.Core.DataPortalException: DataPortal.Fetch failed (DataPortal.Fetch failed (Method not found: ‘!!0[] System.Array.Empty()’.)) —> Avontus.Core.Reflection.CallMethodException: DataPortal_Fetch method call failed —> Avontus.Core.DataPortalException: DataPortal.Fetch failed (Method not found: ‘!!0[] System.Array.Empty()’.) —> Avontus.Core.Reflection.CallMethodException: DataPortal_Fetch method call failed —> System.MissingMethodException: Method not found: ‘!!0[] System.Array.Empty()’. at Avontus.Rental.Library.ExistsGeneric.DataPortal_Fetch(Criteria criteria) at dm(Object , Object[] ) at Avontus.Core.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) — End of inner exception stack trace — at Avontus.Core.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) at Avontus.Core.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) — End of inner exception stack trace — at Avontus.Core.DataPortal.Fetch(Type objectType, Object criteria) at Avontus.Core.DataPortal.Fetch[T](Object criteria) at Avontus.Rental.Library.ExistsGeneric.JobSiteHasInvoices(Guid stockingLocationID) at Avontus.Rental.Library.StockingLocation.LoadHasBilling() at Avontus.Rental.Library.StockingLocation.Fetch(SafeDataReader dr, Boolean prefetchChildren) at Avontus.Rental.Library.StockingLocation.DataPortal_Fetch(RootCriteria criteria) at dm(Object , Object[] ) at Avontus.Core.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) — End of inner exception stack trace — at Avontus.Core.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object[] parameters) at Avontus.Core.Server.SimpleDataPortal.Fetch(Type objectType, Object criteria, DataPortalContext context) — End of inner exception stack trace — at Avontus.Core.DataPortal.Fetch(Type objectType, Object criteria) at Avontus.Core.DataPortal.Fetch[T](Object criteria) at Avontus.Rental.Library.StockingLocation.GetOrganization(Guid StockingLocationID, Boolean prefetchChildren) at Avontus.Rental.Library.Shipment.GetFullShippingAddress(Guid stockingLocationID) at Avontus.Rental.Library.Shipment.get_PreReturnLabelText() at Avontus.Rental.Wrapper.InvTransferService.GetShipment(String ShipmentID) — End of inner exception stack trace —

It’s looking like that error message is related to not having .NET 4.6 installed. Do you have Quantify installed on the same machine? If not, you should do that. The installer should automatically install .NET 4.6 for you as a prerequisite. If you have it installed, possibly uninstall it and reinstall using the Quantify installer may fix it.

We Installed .NET framework 4.6 and now the error has gone away. Thanks for your assistance.