Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using MFC and .NET dlls in a single project 1

Status
Not open for further replies.

SulikSlayer

Programmer
Nov 16, 2002
17
KG
I have 2 dlls - one build with a MFC support an dthe other is fully managed .NET dll.
Both of them incapsulate a class CBString - in MFC it is something like SCtring, in .NET - like String.

I want to create a project that will be able to use any version of this class by user choice. The idea is to create a single code for using both dll versions.

I created a .h file that will do the choosing.

the code is something like:

#ifdef _MFC_

#pragma unmanaged
#include <.h file declaring my CBString class>

#else

#pragma managed
#using &quot;<the .dll file built with .NET>&quot;
using namespase CBString;

#endif

So, if i write
#define _MFC_
in my code, the .h file will #include my MFC .h file
if i won't - it will be #using namespace and .NET dll

The problems are:

1) I have to include the MFC dll manually in the Project options->Linker->Additional Dependences.

2) I have to use /clr compiler option OR create a Managed Application to use the .NET dll

What I actually want is
Ability to swith between MFC AND .NET dlls using my CODE ONLY. No manual action will do, even no /clr compiler options, not to tell about Project Options settings.

I know there must be a way to do this, but I am completely unable to figure it. That's why I'm looking forward to your help.

Great THANKS in advance.

 
>> 1) I have to include the MFC dll manually in the Project
>> options->Linker->Additional Dependences.

#pragma comment ( lib, &quot;mydllfile&quot;)

Don't know about question #2

Good luck
-pete

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top