Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Migrating an application from ( VC6.0 to ) vs 2003 in MFC/C++ to VS2008

160 views
Skip to first unread message

Ana

unread,
Jun 4, 2009, 5:20:35 PM6/4/09
to
Hi,

Its urgent!

I am migrating an application written in MFC /C++, ATL and using
Webbrowser.
The application does not compile and pops up with many errors which i
have managed to resolve by including a list of libs etc as
afxisapi.h,
afxisapi.inl
afxisapi.rc
eafxis.lib
eafxis.pdb
eafxisd.lib
eafxisd.pdb
nafxis.lib
nafxis.pdb
nafxisd.lib
nafxisd.pdb
as suggested in
http://blogs.msdn.com/jpsanders/archive/2007/12/10/chttpserver-not-included-in-visual-studio-2008.aspx

This builds well without any error but in debug mode as it compiles it
gives an debug assertion failed at afxwin1.inl.

It breaks at afxgetresourcehandle.
Please let me know what am I missing on.
Also on ignoring the assertion message i can half way run my
application.

All and any help / advice will be appreciable.

Thanks in advance,
Ana

Scot T Brennecke

unread,
Jun 6, 2009, 3:47:56 AM6/6/09
to Ana
You told us what file the assertion failure was in, but not what the
code assertion was that failed. Ignoring assertions is not something
you can tolerate, of course. What is the code that failed the assertion?

Ana

unread,
Jun 8, 2009, 9:06:07 AM6/8/09
to
On Jun 6, 3:47 am, Scot T Brennecke <Sc...@Spamhater.MVPs.org> wrote:
> You told us what file the assertion failure was in, but not what the
> code assertion was that failed.  Ignoring assertions is not something
> you can tolerate, of course.  What is the code that failed the assertion?
>
>
>
> Ana wrote:
> > Hi,
>
> > Its urgent!
>
> > I am migrating an application written in MFC /C++, ATL and using
> > Webbrowser.
> > The application does not compile and pops up with many errors which i
> > have managed to resolve by including a list of libs etc  as
> > afxisapi.h,
> > afxisapi.inl
> > afxisapi.rc
> > eafxis.lib
> > eafxis.pdb
> > eafxisd.lib
> > eafxisd.pdb
> > nafxis.lib
> > nafxis.pdb
> > nafxisd.lib
> > nafxisd.pdb
> >  as suggested in
> >http://blogs.msdn.com/jpsanders/archive/2007/12/10/chttpserver-not-in...

>
> > This builds well without any error but in debug mode as it compiles it
> > gives an debug assertion failed at afxwin1.inl.
>
> > It breaks at afxgetresourcehandle.
> > Please let me know what  am I missing on.
> > Also on ignoring the assertion message i can half way run my
> > application.
>
> > All and any help / advice will be appreciable.
>
> > Thanks in advance,
> > Ana- Hide quoted text -
>
> - Show quoted text -

Hi Scott ,
Thanks for the response.
Yes.
The code where it breaks is when I try to load an image on to picture
control and call
HINSTANCE hInst = AfxGetResourceHandle();

Also, It some how looks for ..\Vc7libs\... location for the files it
asserts on.

Thanks.

Best Regards,
Ana

Ajay

unread,
Jun 8, 2009, 9:12:20 AM6/8/09
to

Somewhere you are still using MFC7. You need to recompile all the
projects with VS2008 to make sure that dependency is removed(MFC7) in
all projects.

--
Ajay

Ana

unread,
Jun 8, 2009, 1:55:43 PM6/8/09
to
> Ajay- Hide quoted text -

>
> - Show quoted text -

Hi Ajay,

I have converted the project to recompile with vs 2008.
And it does not appear to me anywhere that its using MFC7.
Please suggest.

Thanks,
Ana

Ajay

unread,
Jun 8, 2009, 2:29:41 PM6/8/09
to

If it doesn't, then why are you getting an assert in VC7 file as you
mentioned earlier? You can run depends.exe on your modules to make
sure that your dependency is correct version of MFC.


--
Ajay

Ana

unread,
Jun 8, 2009, 4:12:29 PM6/8/09
to


I did that aswell,it does not show up any dependency.
Also, just to mention, if i ignore debug assertions and continue, the
application breaks at Webbroswer navigate call.
I understand there is something in propert sheets which i go missing :
(.

Colin Peters

unread,
Jun 9, 2009, 2:15:32 PM6/9/09
to


Ajay is right, you still have dependencies on two different
implementations of MFC. It could be a static library that you import
that mismatches, or an MFC extention dll. I mean it might not be code
directly in your exe, but nonetheless runs in your process.

Ana

unread,
Jun 9, 2009, 3:39:19 PM6/9/09
to
> directly in your exe, but nonetheless runs in your process.- Hide quoted text -

>
> - Show quoted text -

Thanks for your reply.

I have checked for all options in property sheets, but ll go through
again.
I have tried to narrow down the issue, If i call afxgetresourcehandle
in the Cdialog contructor when the scope of the instance is global ,
the debug assertion occurs, ortherwise it works fine.
Please suggest..if my finding have anything with the assertion.

Scot T Brennecke

unread,
Jun 10, 2009, 5:55:46 AM6/10/09
to

Ana,
You still never answered my question: what is the code that is failing
the assertion? You only told me the code that makes the function call.
When an assertion failure occurs, you typically get a dialog box,
giving you the opportunity to break into the debugger on the line where
the assertion failed -- usually a line beginning with the word ASSERT.
What is that line of code?

Also, to you and Ajay and others: vc7libs is a directory used by the
Microsoft (typically Windows) builds that use the VC++ libraries. It is
probably NOT because of using multiple versions of MFC, as they
suspected. Using Dependency Walker can usually clear up that question,
though.

Ana

unread,
Jun 10, 2009, 9:35:29 AM6/10/09
to
> though.- Hide quoted text -

>
> - Show quoted text -

Yes the code breaks at ....
the debugger reaches the constructor of

CAboutDialog abtdlg;

and the construct for it is defined as below:

CAboutDialog ::CAboutDialog (CWnd* pParent /*=NULL*/)
: CDialog(CAboutDialog ::IDD, pParent)
{
m_Image1.Load(IDR_IMAGE1); // the code breaks here
giving an assertion

dis_in = 0;
.
.
.
}

Load(UINT ires) is a function which calls AfxGetResourceHandle(),
before it can find more resources on the dialog.
ie
CImage::Load(UINT ires)
{
HINTANCE hinst = AfxGetResourceHandle(); // :( .....
// after this code for finding res etc follows
}

Also as mentioned earlier, I have the CAboutDialog instance declared
global.

Please let me know what I need to do to resolve it.

Thanks,
Ana

Ajay

unread,
Jun 10, 2009, 9:44:36 AM6/10/09
to
On Jun 10, 5:55 am, Scot T Brennecke <Sc...@Spamhater.MVPs.org> wrote:
> Also, to you and Ajay and others: vc7libs is a directory used by the
> Microsoft (typically Windows) builds that use the VC++ libraries.

Are you saying that if I have VS2008 and never installed any previous
version, my code will be referening VC7libs directory direclty or
indirectly?

--
Ajay

David Wilkinson

unread,
Jun 10, 2009, 10:00:47 AM6/10/09
to
Ana wrote:
> Also as mentioned earlier, I have the CAboutDialog instance declared
> global.

Why? Global variables are best avoided in C++ programs.

If this variable is global, it may be being initialized before MFC is properly
set up.

If you want to keep the About dialog object alive (for some reason), make it a
pointer member of the application class and initialize it (using new) in your
CWinApp::InitInstance() override. Delete this pointer in ExitInstance(). Or use
auto_ptr member.

--
David Wilkinson
Visual C++ MVP

Ana

unread,
Jun 10, 2009, 1:30:37 PM6/10/09
to

Thanks David, i knew i should do this way, but this aplication worked
fine earlier :( with VC6 and VC7.( Also this is somebody else's code
i m working on.
I tried to resolve it by calling lodd function in the OninitDialog()
and worked well, except for throwing an unhandled exception somewhere
else in the code.

Thanks a ton for the cleaner solution.

There is still a problem with application, which again seems to be a
migrating issue related to webbrowser, but that I ll post in another
thread(if I am stuck again).

Thanks,
Ana

Scot T Brennecke

unread,
Jun 11, 2009, 12:29:40 AM6/11/09
to

Not your code, really. Microsoft's code (which may be called by you)
may have been built from source in a vc7libs directory.

Ajay

unread,
Jun 11, 2009, 9:10:46 AM6/11/09
to
On Jun 11, 12:29 am, Scot T Brennecke <Sc...@Spamhater.MVPs.org>

I am not sure what you mean by Microsoft's code; you dont mean MFC?
IIRC, OP's assert happned in vc7 in MFC code(at least thats how I saw
it), which implies that OP somewhere (directly or indirectly(com))
still has MFC7 code.

--
Ajay

Scot T Brennecke

unread,
Jun 12, 2009, 7:44:02 AM6/12/09
to

I mean code in the Windows OS that uses MFC.

Ajay

unread,
Jun 12, 2009, 8:55:49 AM6/12/09
to

I had no idea windows OS uses MFC :-)

--
Ajay


Scot T Brennecke

unread,
Jun 14, 2009, 2:12:30 PM6/14/09
to

Well, obviously the "core OS" itself (kernel32, ntdll, user32, etc.)
doesn't use MFC. But there are several components/modules distributed
as part of "Windows" that do use MFC.

Ajay

unread,
Jun 15, 2009, 9:36:41 AM6/15/09
to

But you would hope none of this would be tied to a debug version of MFC
(OP's assert ).

Also, last time I checked (thru MSFT), the only time MFC was being
used was in WMI console. That was few years back though.

--
Ajay

Scot T Brennecke

unread,
Jun 16, 2009, 2:12:09 AM6/16/09
to

Actually, she never did share the full location of the assertion
failure, nor the ASSERT statement that failed. I haven't seen a full
path name to the source file even.

I agree that no released MS code would have a dependency on a debug MFC,
but I still haven't seen the evidence of that. There was only a
roundabout possible implication that the path that contained vc7libs was
somehow related.

If you become really curious, you could open up the various modules in
the System32 folder with Dependency Walker just to see how many modules
are still using the MFC42 DLL. But the only reason that DLL is still in
that folder is that several MS components still use it. It is now
maintained by the Windows development team, with periodic hints from the
VC libraries team about what changes were made in the current MFC, just
in case they need to be back-ported to the OS's version. People who are
still using VC6 and depending on the MFC42 DLL in the Windows
distribution are rolling the dice.

Joseph M. Newcomer

unread,
Jun 16, 2009, 11:47:13 AM6/16/09
to
I met one person recently who is building under VS2008 and using the MFC42.DLL library. I
pointed out that there are significant fixes in the CRT, that the MFC versions are
incompatible in numerous ways (turns out they still use the VS6 MFC header files), and
that they are at significant risk. His view was that they had to do this because they had
to use the shared MFC DLL (their apps are using lots of extension DLLs) but they didn't
want to do actual deployment via an installer program.

I found this weird.
joe

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Scot T Brennecke

unread,
Jun 17, 2009, 1:10:33 AM6/17/09
to
Joseph M. Newcomer wrote:
> I met one person recently who is building under VS2008 and using the MFC42.DLL library. I
> pointed out that there are significant fixes in the CRT, that the MFC versions are
> incompatible in numerous ways (turns out they still use the VS6 MFC header files), and
> that they are at significant risk. His view was that they had to do this because they had
> to use the shared MFC DLL (their apps are using lots of extension DLLs) but they didn't
> want to do actual deployment via an installer program.
>
> I found this weird.

Just "weird"? Downright insane, if you ask me. I don't know how to
assist people with such psychosis.

Ajay

unread,
Jun 17, 2009, 9:01:45 AM6/17/09
to

I dont know how thats possible and the implications of mixing two
versions of MFC (is it what they are doing?).

--
Ajay

Joseph M. Newcomer

unread,
Jun 17, 2009, 4:14:36 PM6/17/09
to
No, not mixing, just using the VS2008 compiler to create code that uses MFC42.DLL.

I told them that they were doing the equivalent of juggling bowling balls on thin ice. It
works until you drop one.
joe

Ajay

unread,
Jun 17, 2009, 10:19:27 PM6/17/09
to
On Jun 17, 4:14 pm, Joseph M. Newcomer <newco...@flounder.com> wrote:
> No, not mixing, just using the VS2008 compiler to create code that uses MFC42.DLL.  
>
> I told them that they were doing the equivalent of juggling bowling balls on thin ice.  It
> works until you drop one.

So there are some who like VS2008 IDE better than VS6 :-)

--
Ajay

Joseph M. Newcomer

unread,
Jun 18, 2009, 9:09:05 AM6/18/09
to
They would use VS6 if they could get it; they can't get it for new developers, so they
have to use the old headers and runtimes. THe only observation they made was they could
no longer get VS6 and were forced to move to VS2008 for new developers, but still had to
create code that ran in the old environment.
joe
0 new messages