Solved

fixing or working around a problem with MFC42d.dll

Posted on 2004-08-10
5
15,325 Views
Last Modified: 2013-11-20
Hello, I am trying to compile a WRAPI test program and am having MFC difficulties.

Background:  I am working in C++ .NET 2003 and the program instructions assume Studio 6.0.  Reading threads with other people having earlier compile difficulties over in the Wireless question area, I added the next two lines to stdafx.h

#include <afx.h>
#include <afxwin.h>

Without those, the next, essential line, explodes messily in bad syntax.

#include <ntddndis.h>

Those includes mean the test program, otherwise a console app, needs the appropriate dll.

When I build the program it compiles completely.  On running it tells me "the application has failed to start because MFC42D.DLL was not found.  Re-installing the applicaiton may fix the problem."

No biggie.  I copied MFC42D.dll to my source directory, rebuilt, and got:  "The application or DLL c:\<source>\MFC42D.DLL is not a valid Windows image.  Please check this against your installation diskette."

I don't know enough about MFC to do more then flail at a solution.  I'd appreciate advice on any of the following:

1)  An explanation of the above and how to fix it.

2)  A work around.  Then test program is a console app.  Does ntddndis.h needs MFC (I don't know)?  If not, how can I replace the afx.h & afxwin.h with anything?

3)  I've looked for MFC42D.DLL on my .NET install disks and on Microsoft support.  Where can I find a valid Windows image?

4)  Another way to solve this problem.

Thanks,

Rylen
0
Comment
Question by:rylen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 13

Expert Comment

by:SteH
ID: 11770857
Do you want to use MFC in your project?
Or would a line like
#include <windows.h>
be sufficient. It might be necessary to do some definitions before that line.
0
 
LVL 1

Author Comment

by:rylen
ID: 11775496
Thanks SteH.  This may be a start but unfortunately does not solve the problem yet.  This is currently an MFC because a bit of previous solution I followed led me to insert afx.h and afxwin.h.

I dropped afx.h and afxwin.h for windows.h and have tried to build with "Use of MFC" set to both "Standard Windows Library" and "MFC in static library."  In both cases my results depended on if I'd removed MFC42D.dll and .lib from the source directory.  If I remove them, I get:  "The application has failed to start ..." as above.  If I put them back, I get "The application or DLL .. is not a vaild Windows image ..." as above.
0
 
LVL 13

Accepted Solution

by:
SteH earned 200 total points
ID: 11781157
If you have a console app that uses MFC you need to include afx.h and afxwin.h! Only in a purist approach you would use Win APIs for a console app if you use windows at all. If I use the app wizard to create a console app that support MFC I get the following includes in stdafx.h:

#define VC_EXTRALEAN            // Exclude rarely-used stuff from Windows headers

#include <afx.h>
#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdtctl.h>            // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>                  // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <iostream>  ///< This is support for console operations.

Another thing might be some defines which are not uptodate any more:
See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/vcconmfcvisualcversionnumbers.asp
for versions of MFC shipped with different versions of VC++ and
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/versions.asp
for common controls.

From those sources you should use (automatically?) mfc71.dll and not mfc42.dll (the extra d after the number is only for debug version of those DLLs).

0
 
LVL 13

Expert Comment

by:SteH
ID: 11781165
0
 
LVL 1

Author Comment

by:rylen
ID: 11802554
Thanks.  From this I've gotten a extremly important bit of information.  VC++ 7 is not compatible w/ DLLs from VC++ 6.  I'll be using the links you gave me (and reading and asking questions) to recompile the WRAPI source code to work in .NET.

Rylen
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question