Calling Unmanaged C++ functions from Visual Studio .NET C++ App

D

David Lowndes

I have an unmanaged C++ DLL built in Visual Studio 4.2. This DLL exports a
class, which I want to use in my VC++ .NET 2003 app.
Everything works fine however some of the methods in the exported class take
CString parameters. When I try using these I get a linker error as follows

Mike,

Passing allocated object such as CStrings across the DLL boundary
implies that you have to use the C & MFC DLLs in order to share a
common memory manager. Since your VC4.2 application and your VC2003
application will be linking to different versions of their run-time
libraries, this isn't going to me a match made in heaven.

Basically I think the linker error is telling you you're onto a
non-starter.

If you rebuild your old project with VS2003 and ensure that both
projects are built with MFC as a shared DLL, you should be OK.

Dave
 
G

Guest

Hi All,

I have an unmanaged C++ DLL built in Visual Studio 4.2. This DLL exports a
class, which I want to use in my VC++ .NET 2003 app.
Everything works fine however some of the methods in the exported class take
CString parameters. When I try using these I get a linker error as follows

Error LNK2001: unresolved external symbol "public: void __thiscall
niclt_clScriptEngine::SetIP(class ATL::CStringT<char,class
StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > >)"
(?SetIP@niclt_clScriptEngine@@$$FQAEXV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z)

I have search on Google and although I can find instances of where others
have found similar issue I have found no solution.
I have also tried the Microsoft recommendation in Article 309801 but this
does not work.
Has anyone any idea how to get around this problem.

Mike.
 

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