Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC .NET4
Hi
 
I have a project from the MFC/C++ VS2010, but I need to use ".NET Library" inside of my project. Actually I need to have a native and manged code at same time. So I am trying to use CLI/C++ facilities and integration, for that purpose I created "Empty CLI" project from the VS2010 and then I added all of my MFC source inside of this project, But When I want to the build it, I get these errors:
 
Error 4 error LNK2005: "public: virtual int __thiscall CComboEdit::PreTranslateMessage(struct tagMSG *)" (?PreTranslateMessage@CComboEdit@@UAEHPAUtagMSG@@@Z) already defined in InPlaceList.obj D:\KTC\EWS\Source\EWS-CLI\EngSystem\EngSystem\GridCellCombo.obj EngSystem
 
Error 16 error LNK2005: "protected: void __thiscall CInPlaceList::OnKeyUp(unsigned int,unsigned int,unsigned int)" (?OnKeyUp@CInPlaceList@@IAEXIII@Z) already defined in InPlaceList.obj D:\KTC\EWS\Source\EWS-CLI\EngSystem\EngSystem\GridCellCombo.obj EngSystem
 
Error 15 error LNK2005: "protected: void __thiscall CInPlaceList::OnKeyDown(unsigned int,unsigned int,unsigned int)" (?OnKeyDown@CInPlaceList@@IAEXIII@Z) already defined in InPlaceList.obj D:\KTC\EWS\Source\EWS-CLI\EngSystem\EngSystem\GridCellCombo.obj EngSystem
 
Error 12 error LNK2005: "protected: virtual struct AFX_MSGMAP const * __thiscall CInPlaceList::GetMessageMap(void)const " (?GetMessageMap@CInPlaceList@@MBEPBUAFX_MSGMAP@@XZ) already defined in InPlaceList.obj D:\KTC\EWS\Source\EWS-CLI\EngSystem\EngSystem\GridCellCombo.obj EngSystem
 
Error 17 error LNK1561: entry point must be defined D:\KTC\EWS\Source\EWS-CLI\EngSystem\EngSystem\LINK EngSystem
 

Additionally from the GridCellCombo.cpp I have these library
#include "../stdAfx.h"
#include "../UserView.h"
#include "../GridCtrl_src/GridCell.h"
#include "../GridCtrl_src/GridCtrl.h"

#include "GridCellCombo.h"

 
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
 
any help would be appreciated.
 
Best Regards.
Homay
Posted 6-Apr-13 5:23am
Edited 6-Apr-13 18:30pm
v3
Comments
Sergey Alexandrovich Kryukov at 6-Apr-13 19:16pm
   
Something can always be missing; it's hard to say without seeing your project. I would advise to do the opposite: start from MFC template and then add a CLI option to it. Better yet, migrate to .NET completely: for UI, MFC is nothing good compared to .NET System.Window.Forms of WPF.
—SA

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Somehow you are including some of your source twice. This can happen from a number of scenarios but here are my first guesses:
- You have one or more of the methods implemented in header files instead of the .cpp files (not a good way to do it). The header files are included at least twice somewhere (this part is not uncommon).
- You have a source file included twice in your project.
- Some bizarre things can sometimes happen if your base class is implemented in one dll and a derived class is in a different dll (more details required).
- ...
 
Also, if you have a mixed mode DLL, I believe with VS2010 it needs to be called from a /CLR executable (I have done this with VS2005, but Microsoft changes the rules from version to version and I am not 100% with what the rules are for VS2010). I think it is still correct with VS2010 that you need to first make your .exe mixed mode, then all DLLs in the chain from executable to the DLL you are describing above. No unmanaged DLLs can call managed code. Your mixed mode DLLs can call either managed or unmanaged code.
 
[If I have said something incorrect here, anybody please feel free to jump in and correct me...]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 205
3 DamithSL 165
4 Tomas Takac 144
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 7 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100