VB6 Application crashes with an Access violation - code c0000005 after calling >Net Com Interop Lib which open, reads and close OleDBConnection

Posted on 2014-01-05
Medium Priority
Last Modified: 2014-02-02
My Company have an application build in VB6, which I have been updating for a few years. All new changes are mostly in the way of C# Com Interop Libraries, so eventually porting the main App to .Net will be easier.
We are preparing a big release, which we are out of schedule. The main problem we are experiencing is that the application crashes in testing  PCs, but not in my development one, which is a Windows XP Pro SP3.

The crashing happens calling a method of one of the COM Interop libraries, which is written in C# and built for .Net 4.0. The method call is below:
    ' Create and set preloaded list object
Private Sub LoadPreLoadList(PreloadCategoryID As Integer, NoEnteringOffSiteHours As Boolean)
    Dim intI As Integer
    Dim lngCharPos As Long
    Dim strPreloadName As String
    Dim curPreldItemData As Long
    Dim blnComboHasBeenCleared As Boolean
    Dim PreloadListObj As PreloadedList
    Dim RFIDUserObj As RFIDUser
    Set PreloadListObj = New PreloadedList
    Set PreloadListObj.DBProperties = GetDBPreloadListProperties()
    blnComboHasBeenCleared = False   
    ' Retrieve provided preloaded category
    ' ==> The next line is causing the Access violation
    If PreloadListObj.LoadPreloadedNamesList(PreloadCategoryID) Then
     ==> execution do not pass to this point <==

' Other process ...
End Sub

Open in new window

The LoadPreLoadList() procedure is called from another procedure while loading the form. Before calling LoadPreLoadList() , other COM interop objects are created and methods are called without problem, which also use an OleDBConnection (open, reading and closing it).

One interesting thing is that if a call LoadPreLoadList(), from a button in the form, the operation is clear, no crash.

I'm attaching the WinDbG files for the crashing system and the one from my developmenten PC, which is working without problems.

We have tested in Windows 7 and Windows XP, with same results.
Question by:IdentAKid
  • 4
  • 2
  • 2
  • +1
LVL 35

Expert Comment

ID: 39758848
you should install the vs2008 redistributables at the client pc's. this package is free and can be downloaded from msdn.

'access violation' is pointer error. that means one of the dll's, your application was loading, tries to use an object where the pointer is (address) is invalid. that is most likely be due to a missing dll, I would guess a com add-on for ms office.

note, the vb6 you were using doesn't need these vc.net enhancements but you seem to invoke common components which do.

porting the app to .net probably would also help as your new setup would add the redistributable components.

LVL 47

Expert Comment

ID: 39758945
Is .Net 4 installed on the crashing PC?

Author Comment

ID: 39759254
@Sara, do you mean installing VC++ 2008? If so, the answer is yes, our installer has that package as pre-requisite, so it is installed.
After posting here yesterday, we were able to make the app running in one of our testing VMs by installing different versions of VC+++ (2005, 2008 - like three versions of this,, and 2010).

Although, we haven't been able to make it work in a different VM. On top of that, the VM where the app worked yesterday is not working today (same problem).

@aikimark, yes .Net 4 is installed by the installer (if not present).
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

LVL 47

Expert Comment

ID: 39759470
You might have to reregister the interop

You will need to navigate to the version-specific directory of your .Net framework on your XP box.
LVL 35

Expert Comment

ID: 39759532
do you mean installing VC++ 2008?
I only meant the redistributable package of vs2008. in your logfilet the error occurs after loading

C:\Program Files\Common Files\Microsoft Shared\office14\Cultures\office.odf

Open in new window

and the dll which was not loaded successfully was


Open in new window

'WinSxS' means Windows site by site and is a folder which contains (mostly) references to files residing in other folders like system32 or syswow64. mfc90.dll is the mfc dll for vs2008. if it fails to load, some of its references cannot be loaded. that could be references to former or current msvc dll's (vs2002, vs2003, vs2005, vs2008) or the corresponding .net packages where those dlls rely on. if you installed vs2008 on a computer all those packages were part of the setup. for a client computer, you normally will have the packages installed as there are many programs which would need them. however, on some older systems which were not updated on a regular base you may need to add one or more of these packages.


Author Comment

ID: 39759552
@aikimark, thanks for your interest and yes the installer is registering all interop libraries. As I mentioned before we got the app running at one point, although it failed again and we think it has to be with VC++ redistributable.

Author Comment

ID: 39759588
@Sara, thanks also for your interest in our problem, just to clarify, my VB6 development PC has Visual Studio 2005 (vs2005) installed only. I have developed the .Net 4 libraries in a different PC (Windows 7 Enterprise x64) using Visual Studio 2010 (vs2010) and after compiling the libraries, I moved and register them in my XP Development PC (where VB6 is installed).

Now, the XP machine has Visual C++ 2005 Redistributable (vc++ 2005) installed, as well as vc++ 2008 (as I mentioned before a couple of different versions).

We made the application work again, after reinstalling vc++ 2008 and restarting Windows but after closing the application and reopening, it failed again.

Accepted Solution

IdentAKid earned 0 total points
ID: 39759775
We finally found out what the problem is: we are using a third party component, which is causing the problem. It is an .ocx control, which uses vc++ 2008. Once we remove the component and all references the application runs fine.
Weird thing is that the component has worked without problem in previous versions, and in the current one our customers are using.

Thank you all for taking time to response.
LVL 52

Expert Comment

by:Martin Liss
ID: 39827475
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Implementing simple internal controls in the Microsoft Access application.
If you need to implement application level security in an Access database application or other VBA code, I strongly encourage you to take advantage of Active Directory groups.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question