Is DBFCDX driver .NET 9 compatible

This forum is meant for questions and discussions about the X# language and tools
Post Reply
Jamal
Posts: 360
Joined: Mon Jul 03, 2017 7:02 pm

Is DBFCDX driver .NET 9 compatible

Post 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
Attachments
ConsoleApp_DBFCDX_NET9.zip
(159.62 KiB) Downloaded 1175 times
Last edited by Jamal on Tue Mar 11, 2025 8:27 pm, edited 1 time in total.
User avatar
robert
Posts: 4883
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Is DBFCDX driver .NET 9 compatible

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
Jamal
Posts: 360
Joined: Mon Jul 03, 2017 7:02 pm

Re: Is DBFCDX driver .NET 9 compatible

Post by Jamal »

Thanks Robert! Looking forward to a fix.


Jamal
User avatar
robert
Posts: 4883
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Is DBFCDX driver .NET 9 compatible

Post by robert »

Jamal,

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

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Jamal
Posts: 360
Joined: Mon Jul 03, 2017 7:02 pm

Re: Is DBFCDX driver .NET 9 compatible

Post by Jamal »

Robert,

Sounds good! Take your time. Whenever you need to beta test, please let me know.
Jamal
Posts: 360
Joined: Mon Jul 03, 2017 7:02 pm

Re: Is DBFCDX driver .NET 9 compatible

Post by Jamal »

Hi Robert,

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

I am testing the latest public version 2.24.
User avatar
robert
Posts: 4883
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Re: Is DBFCDX driver .NET 9 compatible

Post by robert »

Jamal,
We have not worked on this yet
.net 9 compatibility is on the list for x# 3.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
Jamal
Posts: 360
Joined: Mon Jul 03, 2017 7:02 pm

Re: Is DBFCDX driver .NET 9 compatible

Post by Jamal »

Robert,

Thank you!

Jamal
JoeD
Posts: 10
Joined: Wed Apr 09, 2025 12:59 pm
Location: Deutschland

Re: Is DBFCDX driver .NET 9 compatible

Post 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
Jamal
Posts: 360
Joined: Mon Jul 03, 2017 7:02 pm

Re: Is DBFCDX driver .NET 9 compatible

Post 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.
Post Reply