Re: Linking VS6.0 DLL to .Net 2003 - CString Error

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thanks for the help !!

David Wilkinson wrote:

sreenubkaimal@xxxxxxxxx wrote:

Please help me with this..

I have a DLL created in Visual C++ 6.0 ( VS 6.0 ).
I am trying to use this DLL in a new wrapper application written using
Visual Studio .net 2003 (C++ - MFC).

My DLL has many methods which uses CString as arguements and return
values.

At first, I got a Link error as

error LNK2019: unresolved external symbol "__declspec(dllimport)
public: static void __cdecl CTestCommon::SetName(class
ATL::CStringT<char,class StrTraitMFC_DLL<char,class
ATL::ChTraitsCRT<char> > >)"
(__imp_?SetName@CTestCommon@@SAXV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@@Z)
referenced in function "public: void __thiscall
CWrapper2003Dlg::OnBnClickedTest(void)"
(?OnBnClickedTest@CWrapper2003Dlg@@QAEXXZ)

I found a KB article as
http://support.microsoft.com/kb/309801

As per this, i should add the following code to Stdafx.h

template class __declspec(dllimport) CStringT<TCHAR, StrTraitMFC<TCHAR,
ChTraitsCRT<TCHAR> > >;
template class __declspec(dllimport) CSimpleStringT<TCHAR>;

But even this is not solving my problem !! It s giving syntax error as

error C2059: syntax error : '<'

I dont know whether this is a silly mistake of mine.. But I am not able
to figure out any solution !!

sreenubkaimal:

You cannot use a VC6 DLL with a VS2003 program, except under very
special circumstances. If you pass library (C++ standard or MFC) objects
there is no way it can work, because the corresponding classes may have
a different layout in the two library versions. CString was completely
changed in VS2002.

You will need to recompile your DLL in VS2003.

David Wilkinson

.



Relevant Pages

  • Re: Linking VS6.0 DLL to .Net 2003 - CString Error
    ... I am trying to use this DLL in a new wrapper application written using ... My DLL has many methods which uses CString as arguements and return ... It s giving syntax error as ... CString was completely changed in VS2002. ...
    (microsoft.public.dotnet.languages.vc)
  • Linking VS6.0 DLL to .Net 2003 - CString Error
    ... I am trying to use this DLL in a new wrapper application written using ... My DLL has many methods which uses CString as arguements and return ... It s giving syntax error as ...
    (microsoft.public.dotnet.languages.vc)
  • Linking VS6.0 DLL to .Net 2003 - CString Error
    ... I am trying to use this DLL in a new wrapper application written using ... My DLL has many methods which uses CString as arguements and return ... It s giving syntax error as ...
    (microsoft.public.vc.mfc)
  • Re: VC++ 6.0 DLL Using CString used in VC++ 2008
    ... CString in both return codes and function arguments. ... There is no way I can change the DLL, so my only idea is that I need to ... compiler-independent interface. ... fantasy world, compiler-dependent interfaces never change). ...
    (microsoft.public.vc.mfc)
  • Re: VC++ 6.0 DLL Using CString used in VC++ 2008
    ... CString in both return codes and function arguments. ... There is no way I can change the DLL, so my only idea is that I need to ... compiler-independent interface. ...
    (microsoft.public.vc.mfc)