Error Mixing Managed and Unmanaged Code

  • Thread starter Thread starter Jared Kail
  • Start date Start date
J

Jared Kail

I've never mixed managed and unmanaged C++ before, but I've done a lot
of "research" out on the web. Using some examples out there, I wrote this:

#using <mscorlib.dll>
using namespace System;

namespace ntMgdCls
{
__nogc class ntUnmgdCls
{
public:
ntUnmgdCls::ntUnmgdCls(void) {}
ntUnmgdCls::~ntUnmgdCls(void) {}
int ntUnmgdCls::DoSomethingUnmanaged(void) { return 1; }
};

public __gc class ntManagedClass
{
public:
int DoSomething(void)
{
ntUnmgdCls * umc = new ntUnmgdCls();
return umc->DoSomethingUnmanaged();
}
};
}

Essentially I want ntUnmgdCls to wrap around some C++ classes that I
need to import from a 3rd party .lib, and use that wrapper from our main
C# app. However, when I do the above, I get these linker failures:

ntMgdCls.obj : error LNK2001: unresolved external symbol "void * __cdecl
operator new(unsigned int)" (??2@$$FYAPAXI@Z)
ntMgdCls.obj : error LNK2001: unresolved external symbol "void __cdecl
operator delete(void *)" (??3@$$FYAXPAX@Z)

I'm sure it's something basic that I'm missing, and figured someone out
here could pick out what's going on in a NY second...my WY seconds are a
bit slower...

Thanks in advance!

Jared
 
Hi. Thanks for the suggestion!!! Unfortunately, I'm using VS2003 (.NET
1.1), so the oldsyntax trick won't work.

Anyone have any other ideas? It seems like this should be pretty
straightforward. What I am missing?

Jared
 
Back
Top