Is DBFCDX driver .NET 9 compatible
Posted: Mon Mar 10, 2025 7:43 pm
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:
This avoids a System Encoding error "No data is available for encoding 1252"
Here is the code:
If I use XSharp.CoreDb.RddInfo(_SET_AUTOOPEN, 1); , i get the following error:
If I commented out the line, I get:
I attached a sample project ConsoleApp_DBFCDX_NET9.zip and testdbf.dbf.
Thanks!
Jamal
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); 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 commented out the line, I get:
I attached a sample project ConsoleApp_DBFCDX_NET9.zip and testdbf.dbf.
Thanks!
Jamal