How to access Oxygene DLL from C++

I have use of a DLL compiled in Oxygene, no source. I want to use it in a C++ application, but GetProcAddress after LoadLibrary can’t find the public methods, perhaps because they are declared within a public class. Any ideas?

More specifically, the DLL has this:

MyClass = public class

public method MyMethod;

An Oxygene app can simply do this:

DLLClass := New(MyClass );
DLLClass .MyMethod;

I don’t know how to do the same with C++, and GetProcAddress can’t find MyMethod directly.

Can you tell me what it’s compiled for ? Island? .NET?

It’s .NET.

I found a workaround, so I’m good.


This topic is live again for me, in a somewhat different form:

I have a .NET Oxygene DLL with a set of methods thus:

[UnmanagedExport] method MyMethod: Integer; stdcall;

There is no class declaration. The DLL is compiled to allow unsafe code and for x86. Dependency Walker finds all the methods with the correct names.

I have a VS c++ console app to access the DLL thus:

typedef int(__stdcall* DLLFuncInt)(int);
DLLFuncInt myIntFunc;
LPCSTR lpProcName;
int  uReturnVal;

hinstLib = LoadLibrary(TEXT("MYDll.dll"));
lpProcName = "MyMethod";
myIntFunc = (DLLFuncInt)GetProcAddress(hinstLib, lpProcName);
uReturnVal = myIntFunc(1);

This code works for an old Delphi DLL with exported methods, but for the Oxygene DLL methods I get an access violation error when I call one of the methods. LoadLibrary and GetProcAddress both return non-NULL pointers.

What am I doing wrong?

If you add any logging to the methods, does the Av happen before the managed method starts, during, or after it ends?

It never actually calls them.

1 Like

I just created a simple DLL with this structure, and it works. Now I need to figure out what is different between the two. DLLs.

Sorry for posting before running this test.

This signature doesn’t have any parameters. But your sample code – uReturnVal = myIntFunc(1); – seems to indicate it requires 1 parameter?

1 Like