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++ / July 2006

Tip: Looking for answers? Try searching our database.

Using a CString-derived class from a DLL file (LNK2019 &Q309801)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael Buechel - 03 Jul 2006 21:02 GMT
Hi NG,

I've copied this from the article Q309801
(http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B309801).

---- schnipp ---------
You may receive an LNK2019 error message when you build a Visual C++ 2005 or
Visual C++ .NET application that uses a CString-derived class from a DLL
file
---- schnapp ---------

I've a similar problem by exporting a CArray derived class. In the article
the wrote the solution is to add

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

to your stdafx.h in your exe project.

I've tried to migrate the statement to my class by wrtiting:

// Forward declaration,
// @note The class CArgument is declared in the exe itself
class CArgument;

// TArray is my template derived from CArray
//
// template <typename _Ty, typename _A = const _Ty&>
// class AFX_EXT_CLASS TArray
//    : public CArray<_Ty, _A>
// {
//     :
//     :

template class __declspec(dllimport) TArray<CArgument, const CArgument&>;
template class __declspec(dllimport) CArray<CArgument, const CArgument&>;

but i get also the LNK2019 error.

Does any one have an idea for this?

Signature

Kind regards, Michael Buechel

while(!sleep())
  sheeps++;

Michael Buechel - 04 Jul 2006 18:17 GMT
I found a solution:

do not use __declspec(dllexport) for the templates in the dll!

in my example this will done by AFX_EXT_CLASS.
remove the AFX_EXT_CLASS or __declspec(dllexport) and
it will work.

Note: You cannot export another class inheritated by the template

Signature

Kind regards, Michael Buechel

while(!sleep())
  sheeps++;


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.