xsharp.eu • Is DBFCDX driver .NET 9 compatible
Page 1 of 1

Is DBFCDX driver .NET 9 compatible

Posted: Mon Mar 10, 2025 7:43 pm
by Jamal
Robert,

I am facing an issue DBFCDX in .NET 9 and C#. I get an exception as shown below when using the dbServer object.
In .NET Framework 4.8, the CDX files file is loaded fine.

I had to add the following line to the Start method:

Code: Select all

 System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); 
This avoids a System Encoding error "No data is available for encoding 1252"
2025-03-10_15-30-58.png
Here is the code:

Code: Select all

using VO;

using static XSharp.Core.Functions;  

System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

XSharp.Core.Functions.SetMacroCompiler(typeof(XSharp.Runtime.MacroCompiler));

string sDbfPath = @"C:\xSharpTests\";

XSharp.CoreDb.RddSetDefault("DBFCDX");
XSharp.Core.Functions.SetAnsi(true);   

XSharp.CoreDb.RddInfo(_SET_AUTOOPEN, 1);  
// XSharp.CoreDb.RddInfo(_SET_AUTOORDER, 1);


DbServer dbf = new DbServer(sDbfPath + "TESTDBF.DBF", true, false, "DBFCDX");   // Exception here 


var i = dbf.OrderInfo(DBOI_INDEXNAME);
var j = dbf.OrderInfo(DBOI_NAME);
var k = dbf.OrderInfo(DBOI_EXPRESSION);
var l = dbf.OrderInfo(DBOI_ORDERCOUNT);

var y = (bool)dbf.SetOrder("LAST");

dbf.Close();

Console.WriteLine("Done!");

If I use XSharp.CoreDb.RddInfo(_SET_AUTOOPEN, 1); , i get the following error:
2025-03-10_15-24-29.png
If I commented out the line, I get:
2025-03-10_15-22-45.png
I attached a sample project ConsoleApp_DBFCDX_NET9.zip and testdbf.dbf.

Thanks!
Jamal

Re: Is DBFCDX driver .NET 9 compatible

Posted: Tue Mar 11, 2025 11:20 am
by robert
Jamal,
I see a few problems when debugging this:


1) XSharp.CoreDb.RddInfo(_SET_AUTOOPEN, 1);
The second value should be a logical (true)

2) The Macro compiler tries to locate several types when loaded for the first time. I see that it fails to locate System.Decimal.Zero when running in .Net 9.
I think .Net 8 introduced a property static decimal INumberBase<decimal>.Zero and therefore the lookup of System.Decimal.Zero fails, causing all kind of side effects.
I will try to fox this, or ask Nikos to have a look at this.

Robert

Re: Is DBFCDX driver .NET 9 compatible

Posted: Tue Mar 11, 2025 11:45 am
by Jamal
Thanks Robert! Looking forward to a fix.


Jamal

Re: Is DBFCDX driver .NET 9 compatible

Posted: Tue Mar 11, 2025 11:50 am
by robert
Jamal,

Don't hold your breath please.
Solving this may take a while.

Robert

Re: Is DBFCDX driver .NET 9 compatible

Posted: Tue Mar 11, 2025 12:05 pm
by Jamal
Robert,

Sounds good! Take your time. Whenever you need to beta test, please let me know.

Re: Is DBFCDX driver .NET 9 compatible

Posted: Fri Jul 25, 2025 8:07 pm
by Jamal
Hi Robert,

I see still see the same issue. Any update on this?

I am testing the latest public version 2.24.

Re: Is DBFCDX driver .NET 9 compatible

Posted: Sat Jul 26, 2025 9:07 am
by robert
Jamal,
We have not worked on this yet
.net 9 compatibility is on the list for x# 3.

Robert

Re: Is DBFCDX driver .NET 9 compatible

Posted: Sat Jul 26, 2025 7:06 pm
by Jamal
Robert,

Thank you!

Jamal

Re: Is DBFCDX driver .NET 9 compatible

Posted: Mon Aug 04, 2025 5:39 am
by JoeD
Hi Jamal,

I was getting the same Error Message in a .net8 Project.
I could solve it by calling the following Line before accessing the Database:

Code: Select all

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
As I understand you now need to Register CodePages before using them.

Best regards
Johannes

Re: Is DBFCDX driver .NET 9 compatible

Posted: Mon Aug 04, 2025 9:45 pm
by Jamal
Hi Joe,

Thanks for the reply, however, I am aware of that and I already call the method as indicated in my post above. The issue is when using XSharp.CoreDb.RddInfo(_SET_AUTOOPEN, true) which tells the RDD to open the CDX automatically when the dbServer is instantiated.

Anyway, Robert mentioned this will be fixed in X# 3.0.