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

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.
Debug-CrashApp.txt
Debug-DevelopPC.txt
IdentAKidAsked:
Who is Participating?
 
IdentAKidConnect With a Mentor Author Commented:
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.
0
 
sarabandeCommented:
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.

Sara
0
 
aikimarkCommented:
Is .Net 4 installed on the crashing PC?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
IdentAKidAuthor Commented:
@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).
0
 
aikimarkCommented:
You might have to reregister the interop
C:\windows\microsoft.net\Framework\v4.0.xxxxx\regasm.exe

You will need to navigate to the version-specific directory of your .Net framework on your XP box.
0
 
sarabandeCommented:
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

C:\Windows\WinSxS\x86_microsoft.vc90.mfc_1fc8b3b9a1e18e3b_9.0.30729.4148_none_4bf5400abf9d60b7\mfc90.dll

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.

Sara
0
 
IdentAKidAuthor Commented:
@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.
0
 
IdentAKidAuthor Commented:
@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.
0
 
Martin LissOlder than dirtCommented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
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.

All Courses

From novice to tech pro — start learning today.