473,806 Members | 2,219 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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(dll import)
public: static void __cdecl CTestCommon::Se tName(class
ATL::CStringT<c har,class StrTraitMFC_DLL <char,class
ATL::ChTraitsCR T<char >)"
(__imp_?SetName @CTestCommon@@S AXV?$CStringT@D V?$StrTraitMFC_ DLL@DV?$ChTrait sCRT@D@ATL@@@@@ ATL@@@Z)
referenced in function "public: void __thiscall
CWrapper2003Dlg ::OnBnClickedTe st(void)"
(?OnBnClickedTe st@CWrapper2003 Dlg@@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(dlli mport) CStringT<TCHAR, StrTraitMFC<TCH AR,
ChTraitsCRT<TCH AR >;
template class __declspec(dlli mport) 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..

Dec 18 '06 #1
4 4921
sr***********@g mail.com 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(dll import)
public: static void __cdecl CTestCommon::Se tName(class
ATL::CStringT<c har,class StrTraitMFC_DLL <char,class
ATL::ChTraitsCR T<char >)"
(__imp_?SetName @CTestCommon@@S AXV?$CStringT@D V?$StrTraitMFC_ DLL@DV?$ChTrait sCRT@D@ATL@@@@@ ATL@@@Z)
referenced in function "public: void __thiscall
CWrapper2003Dlg ::OnBnClickedTe st(void)"
(?OnBnClickedTe st@CWrapper2003 Dlg@@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(dlli mport) CStringT<TCHAR, StrTraitMFC<TCH AR,
ChTraitsCRT<TCH AR >;
template class __declspec(dlli mport) 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
Dec 18 '06 #2
Thanks for the help !!

David Wilkinson wrote:
sr***********@g mail.com 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(dll import)
public: static void __cdecl CTestCommon::Se tName(class
ATL::CStringT<c har,class StrTraitMFC_DLL <char,class
ATL::ChTraitsCR T<char >)"
(__imp_?SetName @CTestCommon@@S AXV?$CStringT@D V?$StrTraitMFC_ DLL@DV?$ChTrait sCRT@D@ATL@@@@@ ATL@@@Z)
referenced in function "public: void __thiscall
CWrapper2003Dlg ::OnBnClickedTe st(void)"
(?OnBnClickedTe st@CWrapper2003 Dlg@@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(dlli mport) CStringT<TCHAR, StrTraitMFC<TCH AR,
ChTraitsCRT<TCH AR >;
template class __declspec(dlli mport) 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
Dec 19 '06 #3
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
sr***********@g mail.com wrote:
Thanks for the help !!

David Wilkinson wrote:
sr***********@g mail.com 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(dll import)
public: static void __cdecl CTestCommon::Se tName(class
ATL::CStringT<c har,class StrTraitMFC_DLL <char,class
ATL::ChTraitsCR T<char >)"
(__imp_?SetName @CTestCommon@@S AXV?$CStringT@D V?$StrTraitMFC_ DLL@DV?$ChTrait sCRT@D@ATL@@@@@ ATL@@@Z)
referenced in function "public: void __thiscall
CWrapper2003Dlg ::OnBnClickedTe st(void)"
(?OnBnClickedTe st@CWrapper2003 Dlg@@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(dlli mport) CStringT<TCHAR, StrTraitMFC<TCH AR,
ChTraitsCRT<TCH AR >;
template class __declspec(dlli mport) 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
Dec 19 '06 #4
sr***********@g mail.com wrote:
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.
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
Dec 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
13129
by: RU | last post by:
Hi, I am working on a porting project to port C/C++ application from unixware C++, AT&T Standard components to g++ with STL on Linux. This application has been working properly on Unixware/C++/AT&T componets environment. I have been able to compile all modules after making necessary changes in LINUX/gcc/STL environment. We have two templates defined XList and XMap.
0
1233
by: Tim Mulholland | last post by:
I am trying to "wrap" an MFC C++ class in Managed C++. I am getting a System.NullReferenceException everytime i try to execute a function. I don't ahve a clue if i'm doing it right, but i'm trying very hard :) Here is my code for the MFC/C++ Class: class ActLib { public:
7
6554
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with LIBCMT(D).DLL. (My requirement is that we can't link with MSVCRT(D).LIB.) Below are steps I've followed, and the resulting problems 1. Using the New Project wizard, generate a Visual C++ .NET Class Library project (call it "Doomed") and a VC++...
3
3238
by: SteveK | last post by:
We have just started converting a large project from VisualStudio 6.0 to VisualStudio 2003. Of course, we're encountering some problems. The first of which involves some CString() constructors not taking arguments that were valid in the 6.0 builds. As a test, a created a simple 2003 project and inserted the following six lines of code in the stdafx.cpp file: #include "stdafx.h" TCHAR x = 't';
2
2449
by: .NET developer | last post by:
Hi , While upgrading my application from vc6 to vc7 I got followin linking errors : __declspec(dllimport) public: class ATL::CStringT<unsigned short,class StrTraitMFC_DLL<unsigned short,class ATL::ChTraitsCRT<unsigned short> > > __thiscall CHPCmdExecFrame::GetStringParam(int,int *)" (__imp_?GetStringParam@CHPCmdExecFrame@@QAE?AV?$CStringT@GV?$StrTraitMFC_DLL@GV?$ChTraitsCRT@G@ATL@@@@@ATL@@HPAH@Z) referenced in function "int __cdecl...
4
2389
by: danip | last post by:
Hi, I used to have the following: class CArchive { public: // create and specify the filename to use CArchive(CString filename, DWORD size); virtual ~CArchive(); CArchive& operator<<(bool b);
0
2559
by: Philip Lowman | last post by:
I am in the process of trying to migrate a couple of build solutions to Visual Studio Express 2005 from VS 2003 Professional and I am running into a weird C/C++ runtime library linking issue when using the /MT compilation option. Our debug solution's /MTd flag works fine and using /MD also seems to work ok. For some reason I can't fathom, when I use /MT, linking the static excutable completely dies (problems resolving symbols in the STL,...
4
1447
by: Mike | last post by:
Hi ! I have some strange problem and I would like to know if it is a bug or not : In my projects, in 2 different .cpp files, I use the same name to define a local structure: file1.cpp : typedef struct TOTO
2
1864
by: SirCodesALot | last post by:
Dear great minds, I am having trouble linking to an external dll and was wondering if anyone out there could help. Here is my class Istat.h #include "afxdisp.h" using namespace System; using namespace System::Runtime::InteropServices;
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10617
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10370
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4328
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.