Sunday 14 March 2004

WorldPay with C#/.NET

I'm in the process of converting an ecom site from ASP 'Classic' to .NET. The site uses the WorldPay gateway COM.

WorldPay supplies sample ASP files: purchase.asp and callback.asp. Purchase.asp "ported" just fine to C# (after using Reference -> Add Reference -> COM -> WorldPay Select COM to import the DLL).

BUT their callback.asp script failed with the following error

System.Runtime.InteropServices.COMException (0x80004005): aspcomp.AspComponentException: AspComponent: Retreiving MTx object context failed
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at WorldPay.COMcallbackClass.processCallback()
at ASP.callback_aspx.Page_Load(Object sender, EventArgs e) in C:\Inetpub\worldpay\callback.aspx:


WorldPay.COMcallbackClass callback = new WorldPay.COMcallbackClass();

I couldn't figure out why one page would work and the other not. Surely it's the same DLL being imported/loaded? Changing the Identity in IIS, removing code, adding try/catch... nothing fixed the problem.

Just as I was about to give up and leave that one page in ASP 'Classic', I remembered long ago reading about a 'compability mode' in ASP.NET. A quick Google revealed this doco on aspcompat=true.

And it works! I could not find a single reference to this Googling for 'WorldPay' 'InterOp' 'Error' or any other likely terms -- surely I'm not the first!?!?

[hmm.. my first blog post...]


  1. hi,

    its a really useful post for me as I am trying to integrate worldpay with c#. In you post you mentioned some DLL files (where could I download these files from?)

  2. Sorry Amir - I posted this almost six years ago. I no longer have any of the WorldPay stuff handy.

    Good luck with your implementation.


Note: only a member of this blog may post a comment.