First: We know the the .net wrapper class provided in the download section.
But because of the OCX Call Interface is very slow we are trying to connect our application via the cfront.dll to navsion.
The casting-problems with ref object-Parameters in DBL_GetFieldData() and DBL_AssignField() are soved by come methods using the DBL_FieldType()-Function to estimate the right type casting.
But we have problems with some other functions:
The attemp to call DBL_Field_2_Str() always causes a "System.NullReferenceException". The function is defiend in c# as:
[DllImport("cfront.dll", SetLastError = true) ]
protected static extern void DBL_Field_2_Str(
[MarshalAs(UnmanagedType.LPStr)]
out string Str, int StrSize,
int hTable, int hRec, int FieldNo);
Another function, DBL_FieldName() causes this error not always, but on several fields:
[DllImport("cfront.dll", SetLastError = true) ]
[return: MarshalAs(UnmanagedType.LPStr)]
protected static extern string DBL_FieldName( int hTable, int FieldNo);
Has anyone an idea, why this errors occur?
Thanks for your support from Solingen, Germany...
greets,
Sven
Comments
Try to use a StringBuilder and not a string in the DBL_Field_2_Str function, I've solved some similar problems using the StringBuilder
In the DBL_FieldName I use a IntPtr in order to receive the name of the field:
[DllImport("cfront.dll", EntryPoint="DBL_FieldName")] unsafe private static extern IntPtr DBL_FieldName(int* hTable, int FieldNo);
unsafe internal string FieldName(int* hTable, int FieldNo)
{
return this.Oem2Char(Marshal.PtrToStringAnsi(DBL_FieldName(hTable, FieldNo)));
}
Best Regads, Emilio
is it posible to post some snipets of code, how you are working with this StringBuilder, and the OEM2CHAR function?
I also have great troubles with .NET DateTime format and C/FRONT Date format. Have you any solution for this?
Thanks in advance.
You have to convert the strings before to write in the database
I also use the string builder in this function:
I solve the problem with the DateTime with this codes:
ReadData:
Write Data:
the same for Time Fields but with the DBL_Time_2_HMST function
Best Regards
I had a lot of things working (everything i needed actually), using the cfront.dll from c#.
But since I installed the new servicepack (1.1 sp1) for .NET, i keep getting errors. The errors occur when calling the first function after init, setnavisionpath(..).
One error is "module 1 error 182". Another one is (translated from dutch, so may differ from the english version) : "The operating system was unable to load the DLL module: . Check if this DLL-module exists. Also check if the other used DLL-modules exist."
So it seems that somewhere it tries to load a dll with name "" (i.e. empty string). Has anyone experienced the same problem, can anyone give me a clue about this? What has changed in .NET and could cause this problem?
Thanks,
Peter
I had the same problem, I found a solution in:
http://dotnet247.com/247reference/msgs/35/177214.aspx
the way is to call the CFRONT code in a new thread:
Salu2, Emilio