Print Page | Close Window

Tip: Beware of the MFC-version in VS2008 SP1

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=13643
Printed Date: 27 May 2024 at 2:37pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Tip: Beware of the MFC-version in VS2008 SP1
Posted By: znakeeye
Subject: Tip: Beware of the MFC-version in VS2008 SP1
Date Posted: 11 March 2009 at 5:11am

I believe the "Codejock Deployment" tool should take the new MFC-version into account. Something like "Do you want to link Toolkit.dll to the latest MFC/CRT version?"

The problem
Some new projects link to the new (bloated) MFC version:
#define _BIND_TO_CURRENT_VCLIBS_VERSION 1 // First in StdAfx.h
 
This makes your exe dependent on MFC 9.0.30729.1, but the codejock lib/dll links to the old (better) version: 9.0.21022.8. After extensive testing, I have seen that this new version is not backwards compatible!
 
Later, when you compile your Setup project using VS 2008 SP1, it will only add the latest (9.0.30729.1) Merge Module (found in %PROGRAMFILES%\Common Files\Merge Modules). This adds some extra 10 MB to your final MSI file and your executable will not run if the older MFC version is not present in the system.
 
Resolution A - use the old MFC-version
1) Before your install VS 2008 SP1, make sure to copy the merge modules and store them on a safe place:
 
Microsoft_VC90_CRT_x86.msm
Microsoft_VC90_MFC_x86.msm
Microsoft_VC90_MFCLOC_x86.msm
policy_9_0_Microsoft_VC90_CRT_x86.msm
policy_9_0_Microsoft_VC90_MFC_x86.msm
policy_9_0_Microsoft_VC90_MFCLOC_x86.msm
 
2) Install SP1.
3) Make sure your Codejock applications do not define  _BIND_TO_CURRENT_VCLIBS_VERSION - anywhere!
4) Make sure your deployment project uses your own merge modules (from the VS 2008 installation).
5) Remove all BCG-includes (AfxControlBars.h etc). Use CWinApp instead of CWinAppEx etc.
 
Resolution B - use the new MFC-version
1) Install SP1.
2) Recompile the Codejock lib/dll with _BIND_TO_CURRENT_VCLIBS_VERSION defined!
 
 
Resolution A requires some more work, but resolution B means 10 MB of useless sh*t in your MSI (BCG ribbon images etc). I'm certainly going to stick with the old version.


-------------
PokerMemento - http://www.pokermemento.com/



Replies:
Posted By: ABuenger
Date Posted: 11 March 2009 at 6:25am
Resolution C - Link everything statically ???



-------------
Codejock support


Posted By: znakeeye
Date Posted: 11 March 2009 at 6:30am
Doesn't help if you define _BIND_TO_CURRENT_VCLIBS_VERSION. (This problem is not Codejock specific.)
 
The main problem is that VS 2008 SP1 has not got the MSM-files you need. (Blame Microsoft!)


-------------
PokerMemento - http://www.pokermemento.com/


Posted By: terrym
Date Posted: 12 March 2009 at 4:28am
We have VS 2008 SP1 and do not get this extra 10mb???   Also we have tested on new installs of OS's without any errors in our applications, however we do have a strange problem that only seems to be happening on XP Home Edition whereby our application crashes when calling:
 
pFrame = CreateNewFrame(pDocument, NULL);
 
from within CSingleDocTemplate
 
Any ideas anybody (sorry its off topic, but got a few customers complaining :()
 


-------------
Thank you,
Terry Mancey

email terry@tmancey.ltd.uk | linkedin www.tmancey.ltd.uk | twitter @tmancey


Posted By: znakeeye
Date Posted: 12 March 2009 at 6:01am
Right... Try this:
 
Create a new MFC application (using SP1). Link statically and build a Release-exe. The size will be around 1732 kB. Then replace "CWinAppEx" with "CWinApp" and remove the "#include <afxcontrolbars.h>" in your StdAfx.h. After compilation the exe size is around 418 kB.
 
And this is for static linking! If you link dynamically, you have to include all MFC/CRT libraries in your distribution, which is around 10 MB.
 
To verify that your installation works you have to install it on a clean Windows 2000/XP machine! As soon as you install a program which deploys MFC, your installation test will give you false positives - since MFC is not removed upon deinstallation!
 
 
Regarding the crash; need more info. Stack trace?


-------------
PokerMemento - http://www.pokermemento.com/


Posted By: terrym
Date Posted: 12 March 2009 at 7:07am
Originally posted by znakeeye znakeeye wrote:

Right... Try this:
 
Create a new MFC application (using SP1). Link statically and build a Release-exe. The size will be around 1732 kB. Then replace "CWinAppEx" with "CWinApp" and remove the "#include <afxcontrolbars.h>" in your StdAfx.h. After compilation the exe size is around 418 kB.
 
And this is for static linking! If you link dynamically, you have to include all MFC/CRT libraries in your distribution, which is around 10 MB.
 
To verify that your installation works you have to install it on a clean Windows 2000/XP machine! As soon as you install a program which deploys MFC, your installation test will give you false positives - since MFC is not removed upon deinstallation!
 
 
Regarding the crash; need more info. Stack trace?
 
Ok we link dynamically and supply the VS 2008 SP1 Redist so it installs all required files, and have tested on Windows 2000, XP, Vista and 7 without issue.  However this problem is totally strange with CreateNewFrame but we cant give a stack trace as we cant get to happen on our XP Home, it only happens on several of our customers.  All of which have XP Home.
 
It simply crashes with above message and thats it, and we then tried to remote debug, but the remote debugger lol for VS 2008 does not work on XP Home as it says not compatible lol.
 


-------------
Thank you,
Terry Mancey

email terry@tmancey.ltd.uk | linkedin www.tmancey.ltd.uk | twitter @tmancey


Posted By: znakeeye
Date Posted: 12 March 2009 at 8:37am
Look out for AntiVirus such as Norton. Especially if you use some kind of hooks (skin manager?).
 
What does GetLastError() give you?


-------------
PokerMemento - http://www.pokermemento.com/


Posted By: terrym
Date Posted: 12 March 2009 at 8:44am
Originally posted by znakeeye znakeeye wrote:

Look out for AntiVirus such as Norton. Especially if you use some kind of hooks (skin manager?).
 
What does GetLastError() give you?
 
As I say it crashes in CreateNewFrame which is called within OpenDocumentFile, once CreateNewFrame is called then it crashes within this windows function and never returns.  So impossible also to do GetLastError etc.
 


-------------
Thank you,
Terry Mancey

email terry@tmancey.ltd.uk | linkedin www.tmancey.ltd.uk | twitter @tmancey



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net