Question

In nutshell, I have a VC++ dll, which connects to a MS Access (.mdb) file and read data. Two Perl scripts will load this same DLL and read same data. Only difference is that the perl scripts are in different folder (say folder 'A' & folder 'B').

  1. When the Perl script in Folder 'A' loads the DLL and opens the Database connection, it is successful.

  2. When the Perl script in Folder 'B' loads the DLL and opens the Database connection, it is not able to open the connection (Exception occurs).

When I look into the Event viewer, I found the following log.

Faulting application name: perl.exe, version: 5.12.1.1201, time stamp: 0x4bed097d
Faulting module name: msjet40.dll, version: 4.0.9756.0, time stamp: 0x49246e48
Exception code: 0xc0000005
Fault offset: 0x0007128f
Faulting process id: 0x1634
Faulting application start time: 0x01cecb4f0080e109
Faulting application path: C:\Perl512\Perl\bin\perl.exe
Faulting module path: C:\Windows\SysWOW64\msjet40.dll
Report Id: 42f2cbc9-3742-11e3-91cd-001b2109685d

enter image description here

OS: Windows 7 Professional 64-bit

MS Office: MS Office 2007 Standard edition (without MS Access full version, Only Access Runtime Engine is installed)

Connection string: strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"D:\\Documents\\LocalFile.mdb\"";

Note: The DLL will always connect to the same MS Access file and uses same Connection string

Since the script from folder 'A' is able to connect to the database, I do not think there is a problem in connection string. Any Idea/clue about the root cause?

let me know, if you need any additional details. Thanks in advance!

Was it helpful?

Solution

I have found the root cause :). The error message 'Unspecified error' is not very helpful though..

Maybe, I have not given enough info to think about the root cause here. anyway, I shall leave the root cause here so that It might be helpful to point out the direction for someone.

The DLL is linked to Perl by using Perl XS. Before calling the DLL function, Perl XS allocated enormous amount of Memory (almost 1.76 GB) for output variables of the function.

Already there is some memory used by the running program. So, the total memory usage is ~ 1.9 GB. When the DLL is trying to open the connection to MS Access database, Msjet40.dll could have been ran out of memory. 'OutOfMemoryException' could have been the appropriate one. But I got 'Unspecified error'.

How did I debug?

  1. (I know , it is funny :)) Initially I was doubtful about the MS Access file. So, I tried to Compact and Repair the MS Access file. Obviously, It didn't work.

  2. Then I have tried to change the OleDbConnection to OdbcConnection. Atleast, this revealed that "System Resource Exceedeed" Exception.

  3. So I started VMMap to analyse the memory usage. There I saw that Enormous amount of memory was allocation in Heap.

Thus located the root cause.

Why there was no problem on Folder "A" perl script?

The folder "A" perl scripts uses less memory before calling the DLL function. So, It does not exceed the memory limit (2 GB) of Windows 32-bit process.

OTHER TIPS

From support.microsoft.com

If you connect to a Microsoft Access database and then you create more than 64 connections in one process, you may receive one of the following error messages:

In Microsoft Visual Studio .NET:    Unspecified error

Steps to reproduce the behavior...


On using the Close method:

The Connection property actually returns a reference to a copy of the ActiveX Data Object (ADO) connection for the active database. Thus, applying the Close method or in anyway attempting to alter the connection through the Connection object’s methods or properties will have no affect on the actual connection object used by Microsoft Access to hold a live connection to the current database.

From Microsoft Dev Center

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top