xsharp.eu • DBFCDX DBServer:SetOrder() fails
Page 1 of 2

DBFCDX DBServer:SetOrder() fails

Posted: Fri Aug 14, 2020 3:45 am
by Jamal
Hi Dev Team!

The following works in VO 2.8 (2838) and fails in X# 2.5b.

The oServer:SetOrder("XNMEB01") returns True, but in X# returns False and thus the CDX file is not updated.
I even removed all index tags and created only one and it still fails. In VO works all the time with one or indexes.

What could be the issue or is it a bug?

I attached a zip file with an empty DBF and CDX.

Code: Select all

method SetOrderTest() as void
            LOCAL ok as logic
            local oServer AS DbServer
            
            oServer := DbServer{"C:TestXNMEA01.dbf", true, false, "DBFCDX"}
            
            if oServer:Used      // this is OK         
                
                ok := oServer:SetOrder("XNMEB01")  // return false in X#
                
                if ok                                       
                    oServer:Append()
                    oServer:FIELDPUT("UNIT_ID", "123456")
                    oServer:Commit()
                endif 
                oServer:Close() 
                
            endif

            return
Jamal

DBFCDX DBServer:SetOrder() fails

Posted: Fri Aug 14, 2020 6:18 am
by Chris
Hi Jamal,

Looks to be working fine here. Which X# build are you using?
Also can you please create a small but full sample reproducing this? Maybe there's something else in the program that causes this as a side effect.

DBFCDX DBServer:SetOrder() fails

Posted: Fri Aug 14, 2020 7:24 pm
by Jamal
Hi Chris,

Thanks for the reply. For some reason now, I don't have an issue locally, however, since I am deploying the app on an Amazon EC2 instance with Windows Server 2019, it fails.

Will investigate further, may be it is a Windows permission issue.

Jamal

DBFCDX DBServer:SetOrder() fails

Posted: Wed Aug 26, 2020 8:04 am
by Jamal
Hi Chis,

I still have the same issue. I tried several DBF files, and regardless how small and simple they are the SetOrder() fails.
The same files as indicated in my other open fine in VO apps and other DBF utilities and can see I see orders and switch among them.The DLL version of all references I report 2.1.0.0 even though the I am using X# 2.5b.

The attached zip file includes a VO terminal app, X# Project, Screenshots and DBF files.

If works one time try again;

Thanks for looking into this issue.
Jamal

DBFCDX DBServer:SetOrder() fails

Posted: Wed Aug 26, 2020 8:14 am
by Chris
Hi Jamal,

Thanks for the sample! I tried it a lot of times, but it always succeeds here...

Can you please enable trapping of all _handled_ exceptions and run again, do you get an error message about a handled exception before the set order fails?

Also, just in (the unlikely) case it makes a diffrence, can you also try targeting a .Net framework version smaller than 4.8, like 4.7 or 4.6?

DBFCDX DBServer:SetOrder() fails

Posted: Wed Aug 26, 2020 8:26 am
by wriedmann
Hi Jamal, hi Chris,
SetOrder() also fails if the macrocompiler cannot be loaded.
Wolfgang

DBFCDX DBServer:SetOrder() fails

Posted: Wed Aug 26, 2020 3:09 pm
by Jamal
Hi Chris, Wolfgang,

There were no exceptions and changing the Framework version did not make a difference.
However, I changed another app's to use the VO dialect from Core, and the test app which uses the Core dialect started working!
So, that led Wolfgang note about the MacroCompiler and may it stayed in memory! I reinstalled X# and made sure the GAC option is clicked, and added a reference the XSharp.Macrocompiler.DLL from the XSharp Dist folder; and now it works fine on another machine!
Let's hop this is the reason.

Thanks!
Jamal

DBFCDX DBServer:SetOrder() fails

Posted: Thu Aug 27, 2020 6:41 am
by wriedmann
Hi Jamal,
maybe there could be another solution: when your main app is a Core dialect app, try to load the runtime manually.
Unfortunately I'm not able to find the correct code pieces, but maybe Chris can help.
Wolfgang

DBFCDX DBServer:SetOrder() fails

Posted: Thu Aug 27, 2020 10:38 pm
by Jamal
Hi Wolfgang,

I think you mean this:

Code: Select all

System.Reflection.Assembly.Load("XSharp.Macrocompiler.DLL");
Of course, the DLL must be in the EXE work directory.

Jamal

DBFCDX DBServer:SetOrder() fails

Posted: Fri Aug 28, 2020 5:47 am
by wriedmann
Hi Jamal,
no, I don't meant this.
Unfortunately I cannot find any reference of it. It is the X# mechanism like the VulcanLoader class in Vulcan..
Wolfgang