Solved

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
11
1,571 Views
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.
Debug-CrashApp.txt
Debug-DevelopPC.txt
0
Comment
Question by:IdentAKid
  • 4
  • 2
  • 2
  • +1
11 Comments
 
LVL 32

Expert Comment

by:sarabande
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.

Sara
0
 
LVL 45

Expert Comment

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

Author Comment

by:IdentAKid
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).
0
 
LVL 45

Expert Comment

by:aikimark
ID: 39759470
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 32

Expert Comment

by:sarabande
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

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
 

Author Comment

by:IdentAKid
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.
0
 

Author Comment

by:IdentAKid
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.
0
 

Accepted Solution

by:
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.
0
 
LVL 45

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.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now