Bug? [workaround] (B4A/B4J) "The given key was not present in the dictionary"

aeric

Expert
Licensed User
Longtime User
Today I found a weird situation when I tried to open my MiniORMUtils project.
I am getting the error:

An error occured.
Error loading file.
The given key was not present in the
dictionary.


I am using B4A v13.50 under Windows 11. This error also happens in B4J v10.50.
I tried opening the same project under Linux Mint (under VM) but there is no error.
If I make a copy of the project file .b4a or .b4j and open it, there is no error!

If you are also facing the same issue, my workaround:
  1. Make a copy of the project file
    OR
  2. Delete .b4a.meta or .b4j.meta
    OR
  3. Add a # at the first line of .b4a.meta or .b4j.meta
Then your project should be opened without errors.

I attach my project in this post.
 

Attachments

  • source.zip
    387.5 KB · Views: 153
Last edited:

aeric

Expert
Licensed User
Longtime User
I suspect this is something related to the .meta file is "UTF8 contains BOM" formatted.
When I was creating my configure-b4x-wine.sh script to read and write the b4xV5.ini file, the script has issue to read the first "AdditionalLibrariesFolder" key.
When I asked Qwen AI chatbot, it said that this is due to the Windows UTF-8 BOM (Byte Order Mark) issue.

Aeric:
No, it only happens when the first key is "AdditionalLibrariesFolder" and not other key like "AutoBackup". It also work normally if first line is a comment.

Qwen:
You've perfectly pinpointed the symptom of a Windows UTF-8 BOM (Byte Order Mark) issue.

When B4A/B4J creates b4xV5.ini, it often writes it as UTF-8 with BOM. The BOM (EF BB BF) is invisible but sits at the very start of the file. If AdditionalLibrariesFolder is the first key, the line actually looks like this to grep/sed: <BOM>AdditionalLibrariesFolder=... Your grep "^AdditionalLibrariesFolder=" fails because ^ doesn't match the invisible BOM bytes. If a comment is first, line 1 is the comment, and line 2 has no BOM, so it works.
 

johnaaronrose

Active Member
Licensed User
Longtime User
Today I found a weird situation when I tried to open my MiniORMUtils project.
I am getting the error:

An error occured.
Error loading file.
The given key was not present in the
dictionary.


I am using B4A v13.50 under Windows 11. This error also happens in B4J v10.50.
I tried opening the same project under Linux Mint (under VM) but there is no error.
If I make a copy of the project file .b4a or .b4j and open it, there is no error!

If you are also facing the same issue, my workaround:
  1. Make a copy of the project file
    OR
  2. Delete .b4a.meta or .b4j.meta
    OR
  3. Add a # at the first line of .b4a.meta or .b4j.meta
Then your project should be opened without errors.

I attach my project in this post.
I've tried workarounds 2 & 3: neither worked. BTW I'm using Ubuntu Noble.
I was reluctant to do workaround 1 but did it: when I opened the project in B4A still got the same error.
 

aeric

Expert
Licensed User
Longtime User
I tested on Linux Mint 22.3 which is based on Ubuntu noble with the project attached on first post.
After deleted the meta file, I can open the project with no error.

B4A-14.00-01.pngB4A-14.00-02.png
 

johnaaronrose

Active Member
Licensed User
Longtime User
I tested on Linux Mint 22.3 which is based on Ubuntu noble with the project attached on first post.
After deleted the meta file, I can open the project with no error.

View attachment 173721View attachment 173722
Still getting same problem: error window disappears after a few seconds but no coding is displayed i.e. the project is not loaded. Below is link on my box.com to a screenshot of the whole screen, as the screenshot file is too big at 600k+ for this forum:
https://app.box.com/s/1x5qufyz6li8ngze364x3070h1zowztw
Above link is for just viewing screenshot within browser.
Link to download it is:
https://app.box.com/index.php?rm=bo...8ngze364x3070h1zowztw&file_id=f_2481876875115
 
Last edited:

aeric

Expert
Licensed User
Longtime User
Still getting same problem: error window disappears after a few seconds but no coding is displayed i.e. the project is not loaded. Below is link on my box.com to a screenshot of the whole screen, as the screenshot file is too big at 600k+ for this forum:
https://app.box.com/s/1x5qufyz6li8ngze364x3070h1zowztw
Above link is for just viewing screenshot within browser.
Link to download it is:
https://app.box.com/index.php?rm=bo...8ngze364x3070h1zowztw&file_id=f_2481876875115
Try unzip this file and copy the HttpsExample.b4a.meta file to your project.

edit: or rename HttpsExample.b4a.meta.txt to HttpsExample.b4a.meta
 

Attachments

  • HttpsExample.zip
    14.2 KB · Views: 17
  • HttpsExample.b4a.meta.txt
    55 bytes · Views: 15

johnaaronrose

Active Member
Licensed User
Longtime User
I've now done that and the project opens OK except for not finding the .bal files corresponding to the 2 BXPages. I've tried 'Add Files' in the Designer but it doesn't find them in either the Files folder of the project or from a temporary location that I've copied them to. I've even tried Tools->Clean Unused files but that doesn't find or delete them. I've attached the project's .zip file..
 

Attachments

  • HttpsExample.zip
    11.7 KB · Views: 16

aeric

Expert
Licensed User
Longtime User
It's better you start a new thread for your question.

I tried open in Linux Mint under VM. No problem opening the layouts.

1790167486293.png
 
Last edited:

mcqueccu

Expert
Licensed User
Longtime User
I've now done that and the project opens OK except for not finding the .bal files corresponding to the 2 BXPages. I've tried 'Add Files' in the Designer but it doesn't find them in either the Files folder of the project or from a temporary location that I've copied them to. I've even tried Tools->Clean Unused files but that doesn't find or delete them. I've attached the project's .zip file..
The Bal Files, Open the Designer and Add it through there
 

johnaaronrose

Active Member
Licensed User
Longtime User
I've tried the correct way but still have the same 'error' issue in the Log. However, the .bal files are shown when I click the 'Files Manager' in the IDE and the files are in the Files directory of the B4A directory of the project, even though the Warnings about the Files not being in the Files tab are still on the Logger.
The project compiles OK but on running it, the Logger shows Error occurred on line starting with Root.LoadLayout (in code below) with "Invocation Target Exception", presumably due to the .bal file entry somewhere not being created properly. I'm baffled!

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    B4XPages.SetTitle(Me, "Main")
    HttpsPage.Initialize
    B4XPages.AddPage("Https Page", HttpsPage)
End Sub

the attached file contains the relevant .bal, .b4a, .b4a.meta and .bas files.
 

Attachments

  • HttpsExample.zip
    3.4 KB · Views: 16
Last edited:
Top