Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / December 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sreenubkaimal@gmail.com - 18 Dec 2006 08:08 GMT
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 !!

PLease help...

Sree..
David Wilkinson - 18 Dec 2006 09:48 GMT
> Please help me with this..
>
[quoted text clipped - 31 lines]
> 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
sreenubkaimal@gmail.com - 19 Dec 2006 00:36 GMT
Thanks for the help !!

> > Please help me with this..
> >
[quoted text clipped - 43 lines]
>
> David Wilkinson
sreenubkaimal@gmail.com - 19 Dec 2006 07:14 GMT
But if i recompile it in VS.net , will I b able to call the dll from a
wrapper written in VS 6.0 ?

I think i need to explain it ..

The main prob is that
1. The DLL can be created using .Net 2003 OR  VS 6.0.  (It should be an
MFC dll)
2. The DLL exposes classes and methods which uses CString.
3. Wrapper should be written in both .Net and VS 6.0 , for the same
dll.

Please help !!

Thanks a lot for all help..

Regards
Sreenu

> Thanks for the help !!
>
[quoted text clipped - 45 lines]
> >
> > David Wilkinson
David Wilkinson - 19 Dec 2006 11:25 GMT
> But if i recompile it in VS.net , will I b able to call the dll from a
> wrapper written in VS 6.0 ?
[quoted text clipped - 7 lines]
> 3. Wrapper should be written in both .Net and VS 6.0 , for the same
> dll.

The caller and the DLL have to use the same version of the compiler. So
if you want to use the DLL from both a VC6 caller and a VS2003 one, you
need two versions of the DLL.

David Wilkinson

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.