473,473 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VC6 and VC7 applications and DLLs coexistence

Hi Friends,

I'm facing a situation as follows, need help on identifying possible issues.

There is an MFC application developed in VC6.0, say ABCVC6.exe and another
developed in VC.NET, say DEFVCNET.exe. There are a few DLLs that are to be
used
by these applications. All these DLLs are originally developed in VC6.0 but
some of them are now migrated to VC.NET. So, let's say we have PQRVC6.dll
and XYZVCNET.dll.

Can ABCVC6.exe and DEFVCNET.exe can work simultaneously and use the DLLs
too?
What could be the possible issues regarding system DLLs like mfc/ole dlls
etc?

Thanks in advance for your ideas/thoughts/comments.

Regards,
Devender...

Nov 17 '05 #1
11 2264
To the best of my knowledge, it should all be fine. As for VC6.exe and
VCNET.exe using the same DLL(s) simultaneously - all I know is that DLLs are
meant to be instance based - that's why you can use LoadLibrary();. Every
instance of a DLL has its own memory space etc. Plus an instance is created
at run time if your application imports functions from it. If you need to
communicate between instances use data segments like so:

// include files

#pragma data_seg(sharedsectionxyz)
// variables go here.
CLinkedList<CInstanceInfo_Base> g_llInstances;
#pragma data_seg()
#pragma comment(linker, "/SECTION:sharedsectionxyz,RWS")
/* it's been a while since I've done this, I think the only thing
that might go wrong is the linker thing, but it looks alright
on a second glance */
// DllMain etc.

Hope that helps, if you need anything more, just email kawahee AT gmail DOT
com.

-- Todd

"Devender Khari" wrote:
Hi Friends,

I'm facing a situation as follows, need help on identifying possible issues.

There is an MFC application developed in VC6.0, say ABCVC6.exe and another
developed in VC.NET, say DEFVCNET.exe. There are a few DLLs that are to be
used
by these applications. All these DLLs are originally developed in VC6.0 but
some of them are now migrated to VC.NET. So, let's say we have PQRVC6.dll
and XYZVCNET.dll.

Can ABCVC6.exe and DEFVCNET.exe can work simultaneously and use the DLLs
too?
What could be the possible issues regarding system DLLs like mfc/ole dlls
etc?

Thanks in advance for your ideas/thoughts/comments.

Regards,
Devender...

Nov 17 '05 #2
Thanks Todd for a very prompt reply.

I have an MFC DLL built in .Net and want to use it in an exe built in VC 6.
That's giving me some problems.
Any ideas on that?

Thanks & Regards,
Devender...
"Todd Aspeotis" <Todd As******@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
To the best of my knowledge, it should all be fine. As for VC6.exe and
VCNET.exe using the same DLL(s) simultaneously - all I know is that DLLs are meant to be instance based - that's why you can use LoadLibrary();. Every
instance of a DLL has its own memory space etc. Plus an instance is created at run time if your application imports functions from it. If you need to
communicate between instances use data segments like so:

// include files

#pragma data_seg(sharedsectionxyz)
// variables go here.
CLinkedList<CInstanceInfo_Base> g_llInstances;
#pragma data_seg()
#pragma comment(linker, "/SECTION:sharedsectionxyz,RWS")
/* it's been a while since I've done this, I think the only thing
that might go wrong is the linker thing, but it looks alright
on a second glance */
// DllMain etc.

Hope that helps, if you need anything more, just email kawahee AT gmail DOT com.

-- Todd

"Devender Khari" wrote:
Hi Friends,

I'm facing a situation as follows, need help on identifying possible issues.
There is an MFC application developed in VC6.0, say ABCVC6.exe and another developed in VC.NET, say DEFVCNET.exe. There are a few DLLs that are to be used
by these applications. All these DLLs are originally developed in VC6.0 but some of them are now migrated to VC.NET. So, let's say we have PQRVC6.dll and XYZVCNET.dll.

Can ABCVC6.exe and DEFVCNET.exe can work simultaneously and use the DLLs
too?
What could be the possible issues regarding system DLLs like mfc/ole dlls etc?

Thanks in advance for your ideas/thoughts/comments.

Regards,
Devender...

Nov 17 '05 #3
Hallo Devender!
I'm facing a situation as follows, need help on identifying possible issues.

There is an MFC application developed in VC6.0, say ABCVC6.exe and another
developed in VC.NET, say DEFVCNET.exe. There are a few DLLs that are to be
used
by these applications. All these DLLs are originally developed in VC6.0 but
some of them are now migrated to VC.NET. So, let's say we have PQRVC6.dll
and XYZVCNET.dll.

Can ABCVC6.exe and DEFVCNET.exe can work simultaneously and use the DLLs
too?
What could be the possible issues regarding system DLLs like mfc/ole dlls
etc?


Usually they can cooexists, but it depends on the way you use and
compiled the DLL's.
MFC-Extension DLL's must be compiled and bound to the same shared MFC
DLL like your application.
If you rae just building regular DLL's or using the staticly linked
version of the MFC it is also no problem.

Problems will occure if you use different versions of the CRT to
allocate and free the memory. I.e. new/malloc called in one DLL, and
delete/free form another DLL both linked to different CRT versions.

Also be aware that the memory that is needed for you program might raise
more than you might thought, because CRT and MFC DLL's are loaded more
than once.

Check the situation with DEPENDS.EXE
--
Martin Richter [MVP] WWJD
"In C we had to code our own bugs. In C++ we can inherit them."
FAQ : http://www.mpdvc.de
Samples: http://www.codeguru.com http://www.codeproject.com
Nov 17 '05 #4
Hi Martin,

Thanks for your valuable response.

I have an exe built in vc++ .net and it's using a dll that is also built in
vc++ .net. This dll in turn is using another dll that is built in vc 6. This
is where I'm running into the problem. These DLLs are MFC Regular DLLs with
some GUI (dialog boxes, etc.)

The application crashes in MFC71.dll and the stack shows AfxWinMain
somewhere in the sequence. The MFC library is dynamically linked in the DLLs
and also MFC is used as shared library in the project settings.

Is this scenario workable at all? If yes, can you please suggest how?

Thanks,
Devender...

"Martin Richter [MVP]" <ma************@mvps.org> wrote in message
news:42********@news.grutzeck.local...
Hallo Devender!
I'm facing a situation as follows, need help on identifying possible issues.
There is an MFC application developed in VC6.0, say ABCVC6.exe and another developed in VC.NET, say DEFVCNET.exe. There are a few DLLs that are to be used
by these applications. All these DLLs are originally developed in VC6.0 but some of them are now migrated to VC.NET. So, let's say we have PQRVC6.dll and XYZVCNET.dll.

Can ABCVC6.exe and DEFVCNET.exe can work simultaneously and use the DLLs
too?
What could be the possible issues regarding system DLLs like mfc/ole dlls etc?


Usually they can cooexists, but it depends on the way you use and
compiled the DLL's.
MFC-Extension DLL's must be compiled and bound to the same shared MFC
DLL like your application.
If you rae just building regular DLL's or using the staticly linked
version of the MFC it is also no problem.

Problems will occure if you use different versions of the CRT to
allocate and free the memory. I.e. new/malloc called in one DLL, and
delete/free form another DLL both linked to different CRT versions.

Also be aware that the memory that is needed for you program might raise
more than you might thought, because CRT and MFC DLL's are loaded more
than once.

Check the situation with DEPENDS.EXE
--
Martin Richter [MVP] WWJD
"In C we had to code our own bugs. In C++ we can inherit them."
FAQ : http://www.mpdvc.de
Samples: http://www.codeguru.com http://www.codeproject.com

Nov 17 '05 #5
Devender Khari wrote:
Hi Friends,

I'm facing a situation as follows, need help on identifying possible
issues.

There is an MFC application developed in VC6.0, say ABCVC6.exe and
another developed in VC.NET, say DEFVCNET.exe. There are a few DLLs
that are to be used
by these applications. All these DLLs are originally developed in
VC6.0 but some of them are now migrated to VC.NET. So, let's say we
have PQRVC6.dll and XYZVCNET.dll.

Can ABCVC6.exe and DEFVCNET.exe can work simultaneously and use the
DLLs too?
Most likely NO, but under certain circumstances yes.

If the DLLs expose any stadard library (STL), MFC or ATL classes in their
API (e.g. a function that accepts CString, or returns std::string), it won't
work. The VC6 and VC7 libraries are not compatible at a binary level.

If the DLLs expose an API composed entirey of built-in types, or types that
you defined that don't depend on STL or MFC AND the DLLs properly
encapsulate memory (and other resource) management so that what's allocated
in the DLL is freed in the DLL, then you can mix VC6 and VC7 EXEs/DLLs. If
any of the above is not true, then it wont work.

In practice it'll work only if the DLLs were designed specifically with this
kind of compatibility in mind.

Note that COM DLLs adhere to all of these rules, so COM DLLs will always
work cross-version (since it's really no different from cross-language).
What could be the possible issues regarding system DLLs like mfc/ole
dlls etc?


System DLLs won't be a problem since they're versioned in their names (e.g.
MFC42.DLL, MFC7.DLL). The lower-level OS DLLs are language neutral anyway.
Note that you may end up with multiple CRT versions loaded - as long as the
DLLs manage their own resources correctly, this isn't a problem, but it does
contribute to having a larger memory footprint.

-cd
Nov 17 '05 #6
That's correct. In practice I had to work around this problem by
"flattening" my classes and exposing them as a C interface.

Nov 17 '05 #7
Nemanja Trifunovic wrote:
That's correct. In practice I had to work around this problem by
"flattening" my classes and exposing them as a C interface.


That'll work. In the past I've also put things into COM interfaces (local,
no marshaling support) to accomplish the same.

-cd
Nov 17 '05 #8
Hallo Devender!
I have an exe built in vc++ .net and it's using a dll that is also built in
vc++ .net. This dll in turn is using another dll that is built in vc 6. This
is where I'm running into the problem. These DLLs are MFC Regular DLLs with
some GUI (dialog boxes, etc.)
Usually this should work as I sayed.
The application crashes in MFC71.dll and the stack shows AfxWinMain
somewhere in the sequence. The MFC library is dynamically linked in the DLLs
and also MFC is used as shared library in the project settings.
Shouldn't be the problem.
Is this scenario workable at all? If yes, can you please suggest how?


Carl just wrote more about the main problem of freeing memory with one
CRT that was allocated in another CRT.

If you can isolate all functions to work on an interface or with "C"
style functions it should work.

--
Martin Richter [MVP] WWJD
"In C we had to code our own bugs. In C++ we can inherit them."
FAQ : http://www.mpdvc.de
Samples: http://www.codeguru.com http://www.codeproject.com
Nov 17 '05 #9
I don't use MFC sorry - I've just wrapped the Win32 API up into my own custom
classes. The only advice I can offer is to check if the VC6 and VC7 MFC DLLs
are compatable - and I'm guessing they sure as hell aren't.

Best of luck,

-- Todd Aspeotis
http://www.kyvestudios.deadlyfear.com/ (WIP)

"Devender Khari" wrote:
Thanks Todd for a very prompt reply.

I have an MFC DLL built in .Net and want to use it in an exe built in VC 6.
That's giving me some problems.
Any ideas on that?

Thanks & Regards,
Devender...
"Todd Aspeotis" <Todd As******@discussions.microsoft.com> wrote in message
news:0B**********************************@microsof t.com...
To the best of my knowledge, it should all be fine. As for VC6.exe and
VCNET.exe using the same DLL(s) simultaneously - all I know is that DLLs

are
meant to be instance based - that's why you can use LoadLibrary();. Every
instance of a DLL has its own memory space etc. Plus an instance is

created
at run time if your application imports functions from it. If you need to
communicate between instances use data segments like so:

// include files

#pragma data_seg(sharedsectionxyz)
// variables go here.
CLinkedList<CInstanceInfo_Base> g_llInstances;
#pragma data_seg()
#pragma comment(linker, "/SECTION:sharedsectionxyz,RWS")
/* it's been a while since I've done this, I think the only thing
that might go wrong is the linker thing, but it looks alright
on a second glance */
// DllMain etc.

Hope that helps, if you need anything more, just email kawahee AT gmail

DOT
com.

-- Todd

"Devender Khari" wrote:
Hi Friends,

I'm facing a situation as follows, need help on identifying possible issues.
There is an MFC application developed in VC6.0, say ABCVC6.exe and another developed in VC.NET, say DEFVCNET.exe. There are a few DLLs that are to be used
by these applications. All these DLLs are originally developed in VC6.0 but some of them are now migrated to VC.NET. So, let's say we have PQRVC6.dll and XYZVCNET.dll.

Can ABCVC6.exe and DEFVCNET.exe can work simultaneously and use the DLLs
too?
What could be the possible issues regarding system DLLs like mfc/ole dlls etc?

Thanks in advance for your ideas/thoughts/comments.

Regards,
Devender...


Nov 17 '05 #10
Hi Carl,

Thanks a lot for your inputs. I made it work by changing MFC arguments in
the exported functions of DLLs into the Windows built in types. I'm facing
an issue though, it is as follows:

I have a Wizard application ABC.exe that is calling a DLL (FIRST.dll) which
has a class exported. This class has all the pure virtual functions. Another
class in the DLL is derived from CDialog and this exported class using
multiple inheritance. This new CDialog based class implements those virtual
functions. ABC.exe and FIRST.dll are compiled in VC7. There is another DLL
(SECOND.dll) that exports a few APIs using Windows built in types as
arguments. The SECOND.dll is compiled in VC6. From the OnPaint handler in
FIRST.dll we call an onPaint exported function of SECOND.dll. Earlier we
were passing a CPaintDC pointer typecast to CDC pointer but now we have
changed it HDC. And in SECOND.dll we are calling FromHandle(hDC) to get a
CDC object. This resulted in crash. Then we changed it as follows:
CDC* pCDC = new CDC();
pCDC->Attach(hDC);

// handling code

if(pCDC)
{
pCDC->Detach();
delete pCDC;
}

This also result in crash but with a totally different stack.

CPaintDC object that is passed from FIRST.dll to SECOND.dll is created using
'new'.

Could you please suggest what's going wrong?

Thanks,
Devender...

"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam >
wrote in message news:uU*************@TK2MSFTNGP15.phx.gbl...
Nemanja Trifunovic wrote:
That's correct. In practice I had to work around this problem by
"flattening" my classes and exposing them as a C interface.
That'll work. In the past I've also put things into COM interfaces

(local, no marshaling support) to accomplish the same.

-cd

Nov 17 '05 #11
Devender Khari wrote:
Hi Carl,

Thanks a lot for your inputs. I made it work by changing MFC
arguments in the exported functions of DLLs into the Windows built in
types. I'm facing an issue though, it is as follows:

I have a Wizard application ABC.exe that is calling a DLL (FIRST.dll)
which has a class exported. This class has all the pure virtual
functions. Another class in the DLL is derived from CDialog and this
exported class using multiple inheritance. This new CDialog based
class implements those virtual functions. ABC.exe and FIRST.dll are
compiled in VC7. There is another DLL (SECOND.dll) that exports a few
APIs using Windows built in types as arguments. The SECOND.dll is
compiled in VC6. From the OnPaint handler in FIRST.dll we call an
onPaint exported function of SECOND.dll. Earlier we were passing a
CPaintDC pointer typecast to CDC pointer but now we have changed it
HDC. And in SECOND.dll we are calling FromHandle(hDC) to get a CDC
object. This resulted in crash. Then we changed it as follows:
CDC* pCDC = new CDC();
pCDC->Attach(hDC);

// handling code

if(pCDC)
{
pCDC->Detach();
delete pCDC;
}

This also result in crash but with a totally different stack.

CPaintDC object that is passed from FIRST.dll to SECOND.dll is
created using 'new'.

Could you please suggest what's going wrong?


I can't, but maybe someone else can. I don't use MFC (in fact, as a general
rule I don't write GUI code at all), but you might try asking on
microsoft.public.vc.mfc if you don't get an answer here.

-cd
Nov 17 '05 #12

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

Similar topics

3
by: Craig | last post by:
I've developed an single sign on web application that we'd like to use with all the applications we're developing. The application's connection string is stored in web.config. I've gotten some...
5
by: Martin Kock | last post by:
Hi, I'm writing a small application in Borland C++ Builder 4. Just for your information, it is a win32 application with a GUI, programmed in WinXP, but supposed to run on Win98. Anyways, my...
4
by: Michael | last post by:
Hi! I've written some simple games and now I want to create installers for them. I've added the thrid party dlls that I use (fmod, libsdl..) but my games also need certain Visual Studio .NET dlls....
5
by: Max | last post by:
I have several web applications I'm trying to upload to my web site, but it seems to be only letting one run at a time. It's totally ignoring the new bin folder in my subdirectory. Is there...
7
by: Mat | last post by:
I would like to build multilanguage applications -user may have options, in runtime to change the language(switch). -i may need to update languages (grammar..) without rebuild to applications. ...
0
by: russell.thamm | last post by:
Can I leverage assemblies to avoid DLL hell with unmanaged code? I have an unmanaged application that I have ported from MSVC6 to Visual Studio 2005. This application is a distributed application...
3
by: Jim Horvath | last post by:
I know how to create exe applications in dotnet that use functions supplied by pre-existing dlls. How do you turn that around? I want to create an exe program that will be the pre-existing piece....
0
by: z71mdridin | last post by:
I have several vb.net common code libraries that are used throughout multiple applications in our enterprise. For example, we have code libraries to handle logging, error handling, database...
7
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
I did my MCAD sometime ago in 1.1, using the 305 manual. I've since moved up to VS 2005. I've created perhaps a half dozen Dot Net 2.0 web applications. (Click on the Create Project link within...
0
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...
0
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,...
0
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,...
1
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.