Error 31 (ERROR_GEN_FAILURE) using IIS

Support for the Milan Intelligent interface, sold by Money Controls as the Paylink USB unit and for the earlier PCI card version.

Moderators: aardvark, davebush, Admin

Post Reply
Nathan
Posts: 41
Joined: Tue Oct 30, 2018 4:12 pm

Error 31 (ERROR_GEN_FAILURE) using IIS

Post by Nathan »

Hi,

I have a Paylink controller that I'm trying to access from a .NET (4.5) program in C#.
I have this code running on several computers and it works correctly, but on one particular computer, the following line throws an error:

var OpenRes = AESImhei.OpenMHE();

I expect the result to be 0, but I'm getting error 31 (ERROR_GEN_FAILURE).

However, the demo program (demo.exe) is working and connects to the controller correctly.

Nathan
Last edited by Nathan on Mon Mar 31, 2025 2:42 pm, edited 1 time in total.
davebush
Posts: 482
Joined: Fri Oct 22, 2004 12:20 pm

Re: Error 31 (ERROR_GEN_FAILURE)

Post by davebush »

Hi Nathan,

The Paylink driver and the DLL communicate using a shared memory segment, and error 31 means that for some reason the DLL is unable to open the segment correctly.

This can be due to access permissions if you are running the application in an unusual way. Can you think of any way the failing PC is different?

Dave
Aardvark software developer. Please put all communication on the problem through the board for the benefit of others.
Nathan
Posts: 41
Joined: Tue Oct 30, 2018 4:12 pm

Re: Error 31 (ERROR_GEN_FAILURE)

Post by Nathan »

Hi,

The only thing that comes to mind is that the PC where this installation is running was set up more recently than the others.

In my older setups I was using 32-bit programs and it could be that in previous installations, while in this newer installation, the programs are 64-bit.

Maybe since my application uses the 32-bit version, they may not be able to share the same memory address.

I have had problems with the DLL (32 or 64 bits). In my previous project, I used the 32-bit version and had to configure the application pool in IIS to support 32-bit applications.

Nathan
davebush
Posts: 482
Joined: Fri Oct 22, 2004 12:20 pm

Re: Error 31 (ERROR_GEN_FAILURE)

Post by davebush »

Hi,

There is a problem to do with users, which I think is related to IIS. (It may be only on 64 bit)

With IIS the application is not running as the normal user, while the driver program is.

As these are running as different users, that means that shared memory has to be in the "global segment" - at which point everyone on the machine can access it.

You achieve this by putting the line

Code: Select all

Use Global Segment
in Standard.cfg after the Driver line.

In order for the driver program to be able to do this, you will have to run it with Administrator privileges. There's no need to change your application.

Regards

Dave
Aardvark software developer. Please put all communication on the problem through the board for the benefit of others.
Nathan
Posts: 41
Joined: Tue Oct 30, 2018 4:12 pm

Re: Error 31 (ERROR_GEN_FAILURE)

Post by Nathan »

That was it Dave.
Solved.
Thank you for your help.

Nathan
Post Reply