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,740 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
11 Comments
 
LVL 34

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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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
 
LVL 34

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 48

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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

691 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