Developer forum

Forum » Development » FeeProvider crashes IIS

FeeProvider crashes IIS

Gaetan Di Caro
Reply

Hello,

I have written a feeprovider for our new shop. It does work absolutely fine in local, however when I copy the project DLL on the server, it makes IIS crash with this error :

Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7afa2

Faulting module name: nlssorting.dll, version: 4.0.30319.18408, time stamp: 0x52310504

Exception code: 0xc00000fd

Fault offset: 0x000000000000440f

Faulting process id: 0x12bc

Faulting application start time: 0x01d0be063ca4c302

Faulting application path: c:\windows\system32\inetsrv\w3wp.exe

Faulting module path: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\nlssorting.dll

Report Id: 8302f72a-29f9-11e5-8e91-005056bd5e51

 

Unfortunately I haven't been able to find more detailed info on the error, windows isn't very detailed about this. If I comment my feeprovider, it works fine, so I know it comes from there, but I cannot see the problem.

Here is the code, it is pretty straightforward :

public class FreeShippingProcessing : FeeProvider
{
    public override PriceRaw FindFee(Order Order)
    {
        PriceRaw returnFee = null;

        try
        {
            User user = User.get_Current(PagePermissionLevels.Frontend);
            string val = string.Empty;

            if (user != null)
            {
                Context.Cart.ShippingMethodID = Shipping.getAllShippingmethods().FirstOrDefault(x => x.Name == "BKI").ID;

                if (Context.Cart.TotalPriceWithoutTaxes.Price >= 1900)
                {
                    returnFee = new PriceRaw(0.00, Order.Currency);
                }
                else
                {
                    CustomFieldValue discountCode = user.CustomFieldValues.FirstOrDefault(x => x.CustomField.SystemName == "AccessUser_Fakturarabatkode");
                    if (discountCode != null && discountCode.Value != null)
                    {
                        val = discountCode.Value.ToString().Trim();

                        if (val != "99")
                        {
                            returnFee = new PriceRaw(0.00, Order.Currency);
                        }
                    }
                }
            }
        }
        catch (Exception e)
        {
            LogToFile.Log(e.Message, "FindFee", LogToFile.LogType.ManyEntriesPerFile);
            LogToFile.Log(e.StackTrace, "FindFee", LogToFile.LogType.ManyEntriesPerFile);
            return null;
        }

        return returnFee;
    }
}

Notice the log inside the catch... but nothing gets logged.

Anyone has an idea ?

Thank you !


Replies

 
Morten Snedker
Reply

Can you try and build your VS-project with 4.5.1 as your target framework....

If problem still occurs, please post the error from IIS once again.

 

/Snedker

 
Morten Snedker
Reply

ALSO: please check: is your 404 page (in Dynamicweb) unpublished? If so, please publish it.

 

/Snedker

 
Gaetan Di Caro
Reply

Hi Morten,

I already build it using 4.5.1.

Thanks !

 
Gaetan Di Caro
Reply

I haven't set a custom 404 page for this website.

Thanks !

 
Gaetan Di Caro
Reply

I've checked the IIS configuration between my computer and the server, but I don't see any obvious difference. They both run NET 4.0

 
Gaetan Di Caro
Reply

I have managed to find the line of code which causes the problem. The problem occurs when I call Context.Cart.TotalPriceWithoutTaxes.

This makes .NET crash, and doesn't if I comment the line with TotalPriceWithoutTaxes :

PriceRaw returnFee = null;

            try
            {
                User user = User.get_Current(PagePermissionLevels.Frontend);
                string val = string.Empty;

                if (user != null)
                {
                    //BKIShop
                    if (Context.Cart.ShopID == "SHOP7")
                    {
                        Context.Cart.ShippingMethodID = Shipping.getAllShippingmethods().FirstOrDefault(x => x.Name == "BKI").ID;

                        var price = Context.Cart.TotalPriceWithoutTaxes;

                /* Snip rest of comments */
                    }              
            }
            catch (Exception e)
            {
                LogToFile.Log(e.Message, "FindFee", LogToFile.LogType.ManyEntriesPerFile);
                LogToFile.Log(e.StackTrace, "FindFee", LogToFile.LogType.ManyEntriesPerFile);
                return null;
            }

            return returnFee;
        }

 

Any idea of what to do ? I'm quite stumped.

 

Thanks !

 
Gaetan Di Caro
Reply

Also tried to update all the dlls with the ones from the dynamicweb release it uses (8.5.1.9), but to no avail.

 
Gaetan Di Caro
Reply

Ok after talking with Lars Hejgaard Sørensen we fixed it. We suppose that TotalPriceWithoutTaxes calls the feeprovider, resulting in an infinite loop. One solution is to add a lock :

if (System.Web.HttpContext.Current.Items.Contains("Busy"))
{
  return null;
}

System.Web.HttpContext.Current.Items.Add("Busy", true);

// Do stuff

System.Web.HttpContext.Current.Items.Remove("Busy");

However in this case we just removed the comparison to the price and directly used the dynamicweb administration of the shipping for that.

 

You must be logged in to post in the forum