cfront.dll wrapping in c++

  • Thread starter Alfred B. Thordarson
  • Start date
A

Alfred B. Thordarson

I have unsuccessfully searched back and forth for a solution to the
following problem. I hope someone out there can help me.

I have created a C++ .NET wrapper for a 3-rd party C based DLL
(cfront.dll from Navision) but the wrapper access to the DLL doesn't
work for some of the exported functions?!?

To illustrate what I mean, I have created the following small
test-case. You simply compile and link it using the cf.h and libload.c
(from Navision) unchanged. When it runs it throws the following
exception before it starts running:

An unhandled exception of type 'System.TypeLoadException'
occurred in TestCase.exe
Additional information: Could not load type DBL_REC from assembly
TestCase, Version=1.0.1417.19361,
Culture=neutral, PublicKeyToken=null.

However, if the "DBL_HREC hRec=..." line is commented out then it
works fine??!?

-----
#include "stdafx.h"

extern "C" {
#include "cf.h"
}

public __gc class TestClass
{
public:
void executeNavSample() {
SessionInit((DBL_U8 *)"cfront.dll");
DBL_ConnectServerAndOpenDatabase((DBL_U8*)"ndbcn",NULL,
(DBL_U8*)"tcp",(DBL_U8*)"sample.fdb",
10000,1,1,0,0);
DBL_NextCompany(NULL);
DBL_HTABLE hTable;
DBL_OpenTable(&hTable,50000);
// Comment this line out and it works???!?
DBL_HREC hRec=DBL_AllocRec(hTable);
DBL_CloseTable(hTable);
DBL_CloseCompany();
DBL_CloseDatabase();
DBL_Exit();
}
};

int _tmain()
{
TestClass *test=new TestClass();
test->executeNavSample();
return 0;
}
-----

If you could give me some comments on this, it would be very helpful.
You might also be able to redirect me to somewhere or someone that
could possible help me?

If you want I could send you the Visual Studio project and you could
try it out. Just send me an e-mail. Thanks in advance and looking
forward to hearing from you.

-Alfred

PS: I compile the file from with in Visual Studio 2003 .NET and the
project is created using the C++ Console Application (.NET) project
template.

The command line arguments used when compiling are: /Od /AI "H:\Visual
Studio Projects\WSTest\Debug" /D "WIN32" /D "_DEBUG" /D "_MBCS" /FD
/EHsc /MTd /GS /Yu"stdafx.h" /Fp"Debug/DirectNavDotNet.pch"
/Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /nologo /c /Zi /clr /TP /FU
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll" /FU
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" /FU
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"

The command line arguments used when linking are: /OUT:"H:\Visual
Studio Projects\WSTest\Debug\DirectNavDotNet.exe" /INCREMENTAL /NOLOGO
/DEBUG /ASSEMBLYDEBUG /PDB:"H:\Visual Studio
Projects\WSTest\Debug/DirectNavDotNet.pdb" /FIXED:No kernel32.lib
user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib
shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top