S
Sam Whited
So I have a managed DLL written in Visual C++ which exports functions to be
used in an external application with generic DLL linking functions.
If I simply return some data my (non .NET) application can call the
functions fine but as soon as I try to allocate memory of of the managed
heap the application crashes without giving me any information. For
instance, I have an initialization function which creates an instance of an
object for other functions to reference (the class contains a static pointer
to an instance of itself so that functions can reference it... it also makes
sure there is only one instance of itself in existence at any one time).
Any ideas how I could create an instance of this class (here called iClass)
on the heap in a COM safe manner (or is that not even the problem)?
namespace iClassSpace
{
public ref class iClass
{
public:
static iClass^ iClass icInstance;
iClass()
{
iClass::icInstance = this;
}
// Other stuff
}
}
extern "C" __declspec( dllexport ) double init()
{
// Crashes right here without ever entering the iClass constructor
gcnew iClass();
return ( 1 );
}
used in an external application with generic DLL linking functions.
If I simply return some data my (non .NET) application can call the
functions fine but as soon as I try to allocate memory of of the managed
heap the application crashes without giving me any information. For
instance, I have an initialization function which creates an instance of an
object for other functions to reference (the class contains a static pointer
to an instance of itself so that functions can reference it... it also makes
sure there is only one instance of itself in existence at any one time).
Any ideas how I could create an instance of this class (here called iClass)
on the heap in a COM safe manner (or is that not even the problem)?
namespace iClassSpace
{
public ref class iClass
{
public:
static iClass^ iClass icInstance;
iClass()
{
iClass::icInstance = this;
}
// Other stuff
}
}
extern "C" __declspec( dllexport ) double init()
{
// Crashes right here without ever entering the iClass constructor
gcnew iClass();
return ( 1 );
}