Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VCS 4.0.34: Unhandled error in clsDbVbeReference.GetDictionary line 162 #495

Open
HughWarrington opened this issue Mar 14, 2024 · 10 comments
Labels
pending resolved Possibly resolved, needs testing or confirmation

Comments

@HughWarrington
Copy link

This was while doing my first full export. Right after these initial log messages:

-------------------------------------
my_database.mdb
VCS Version 4.0.34
Performing Full Export
14/03/2024 17:19:00
-------------------------------------

it said ERROR: Unhandled error found before 'On Error' directive (from memory). I then reran with debugging enabled and got this:

image

OS Name: Microsoft Windows 10 Pro (10.0.19045 Build 19045) 64-bit
VCS version: 4.0.34
Office version: Microsoft® Access® for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20124) 64-bit

I'm new to Access/VBA but can supply more details if needed.

@HughWarrington
Copy link
Author

Can I also just take a moment to praise the maintainers @joyfullservice and I'm sure countless others who have contributed to this project over the years. I'm a newcomer to Access/VBA and I'm taking over the maintenance of a large and ancient project. I can't say how relieved I was to find this kind of tool exists, since the 'version control' on the project I have inherited has nearly 1000 different .mdb files of different ages. Hopefully I will be able to delve into the history in a more meaningful way using this tool plus git and the tools I am familiar with.

@josef-poetzl
Copy link

Is it possible that a reference is broken (missing reference)?
Then ref.Name cannot be executed.
Try ? ref.IsBroken in immediate window if the code execution was stopped in the error line shown above.

@HughWarrington
Copy link
Author

Ah yes I think that is likely. I have had many problems with missing references in this file.

@joyfullservice
Copy link
Owner

@HughWarrington - Thank you for the kind words! That is exactly the kind of scenario where I find this tool so helpful. You can go through each of those mdbs and export the source files, then use WinMerge or other tools to compare the differences between the versions.

Another quick tip on the VBA development side, if you haven't already done so, is to set a couple options in your VBA IDE.

image

image

These tweaks greatly improve the development experience in VBA. (Note that depending on the style of the original developers in your project, requiring variable declaration may be a phased approach if they were not in the habit of declaring them in the VBA code.)

@HughWarrington
Copy link
Author

That's great, thanks for the tips!

I suppose a good improvement here might be to print a warning message 'You have a missing reference' or maybe just to silently ignore it -- if I'm honest I don't know yet what this GetDictionary code is trying to do. Perhaps I will have time to contribute a fix myself in due course.

joyfullservice added a commit that referenced this issue Mar 22, 2024
Warning the user if broken references are encountered, or VBA errors triggered during the export. #495
@joyfullservice
Copy link
Owner

I have added some additional error handling around broken references. A broken reference does not necessarily mean the export will fail, but it is good to warn the user in case they are not already aware of it. In my testing, a broken reference does not always generate an error either, so I added handling for both cases just to make sure it gets visibility.

@joyfullservice joyfullservice added the pending resolved Possibly resolved, needs testing or confirmation label Mar 22, 2024
@josef-poetzl
Copy link

ref.Name will fail if broken ref from a type lib.
=>

If ref.IsBroken Then
   If ref.Kind = vbext_rk_Project Then
      Log.Error eelWarning, "Broken reference for " & ref.Name & " (" & ref.FullPath & "). " & _
                        "This may cause errors in the export process.", ModuleName(Me) & ".GetDictionary"
   Else 'vbext_rk_TypeLib
      ' only guid can be read
      Log.Error eelWarning, "Broken reference for " & ref.Guid & ". " & _
                        "This may cause errors in the export process.", ModuleName(Me) & ".GetDictionary"
   End If
End If

Code can also be designed a little more beautifully, I just wanted to show a possible solution. ;)

joyfullservice added a commit that referenced this issue Mar 22, 2024
Referencing the name property on a broken typelib reference will cause an error. Avoid this condition by testing IsBroken before referencing the name property. #495
@joyfullservice
Copy link
Owner

ref.Name will fail if broken ref from a type lib. =>

Thanks for the suggestion! I have refactored the code to avoid referencing the .Name property on a broken type lib. I didn't have an easy way to test this, but it looks like it should work... 😄

@josef-poetzl
Copy link

josef-poetzl commented Mar 22, 2024

strName = IIf(ref.Type = vbext_rk_Project, ref.Name, ref.Guid)
Will not work because iif is a function in VBA.
=>

if ref.Type = vbext_rk_Project
    strName = ref.Name
else
    strName = ref.Guid
end if

Test with tlb is simple:

  1. Insert a reference to an unregistered tlb file.
  2. close accdb
  3. delete tlb file
  4. => missing reference

@joyfullservice
Copy link
Owner

Good point... I forgot about the fact that VBA will evaluate all the expressions in a function. I will adjust that. 🤦

joyfullservice added a commit that referenced this issue Mar 22, 2024
We don't want the .Name property to be accessed on a broken type lib reference. #495
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending resolved Possibly resolved, needs testing or confirmation
Projects
None yet
Development

No branches or pull requests

3 participants