G
Guest
Hello,
I realize that MS doesn't support managed C++ on CF, but I was wondering if
anyone could help a newbie out....
On the WinCE .NET Emulator, I'm running a simple C# form that calls a method
inside a managed C++ class. That method uses new and delete to create and
destroy an unmanaged C++ object:
Code snippet in my C# form:
try
{
Test.Managed.f();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
C++ code:
namespace Test
{
class Unmanaged
{
public:
Unmanaged() {}
};
public __gc class Managed
{
public:
static void f()
{
// This code causes a MissingMethodException in my form.
Unmanaged* um = new Unmanaged();
delete um;
// This code runs fine.
// Unmanaged um;
}
};
}
If I use the new/delete code in Managed.f(), I get a MissingMethodException
at the function call in my C# form code. I can't even step into Managed.f()
in the debugger. However, if I comment out the new/delete snippet, and
instead use the code below it to create an unmanaged object on the stack, the
code runs fine - no errors. I want to be able to use new and delete on a
pointer - what am I missing? Any thoughts?
Thanks!
I realize that MS doesn't support managed C++ on CF, but I was wondering if
anyone could help a newbie out....
On the WinCE .NET Emulator, I'm running a simple C# form that calls a method
inside a managed C++ class. That method uses new and delete to create and
destroy an unmanaged C++ object:
Code snippet in my C# form:
try
{
Test.Managed.f();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
C++ code:
namespace Test
{
class Unmanaged
{
public:
Unmanaged() {}
};
public __gc class Managed
{
public:
static void f()
{
// This code causes a MissingMethodException in my form.
Unmanaged* um = new Unmanaged();
delete um;
// This code runs fine.
// Unmanaged um;
}
};
}
If I use the new/delete code in Managed.f(), I get a MissingMethodException
at the function call in my C# form code. I can't even step into Managed.f()
in the debugger. However, if I comment out the new/delete snippet, and
instead use the code below it to create an unmanaged object on the stack, the
code runs fine - no errors. I want to be able to use new and delete on a
pointer - what am I missing? Any thoughts?
Thanks!