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
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
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
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
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
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 :
(.
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.
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.
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.
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
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
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
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
Not your code, really. Microsoft's code (which may be called by you)
may have been built from source in a vc7libs directory.
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
I mean code in the Windows OS that uses MFC.
I had no idea windows OS uses MFC :-)
--
Ajay
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.
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
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.
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
Just "weird"? Downright insane, if you ask me. I don't know how to
assist people with such psychosis.
I dont know how thats possible and the implications of mixing two
versions of MFC (is it what they are doing?).
--
Ajay
I told them that they were doing the equivalent of juggling bowling balls on thin ice. It
works until you drop one.
joe
So there are some who like VS2008 IDE better than VS6 :-)
--
Ajay