views:

958

answers:

3

Using Visual Studio 2008, I created a c++ Win32 project. To release the program, I made a visual studio setup project within the same solution. The setup.exe prompts my users to install .Net 3.5 SP1, which is often a 15+ minute install and only allowed to administrator level accounts. If they do not there is an error along the lines of "wrong framework". I am confused over what in my project requires .Net 3.5 SP1. I suspect just because that is the framework my PC is on.. is there a way to broaden which frameworks it will run on? The code is mostly win32 API calls. Just in case, here are my dependancies and #includes:

gdiplus.lib
comctl32.lib
Winmm.lib
d3d9.lib

(the setup project automatically added comdlg32.dll, then tells me to exclude it)

#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <string.h>

#include <commctrl.h>     
#include <process.h>
#include <sstream>
#include <math.h>
#include <d3d9.h>
#include <time.h>
#include <gdiplus.h>

My guess is that somewhere through windows.h there is a WIN_VER or similar version setting that is set to .Net 3.5 SP1, and this is where the dependancy comes from. If that is the case, and I need to define a different version, I would love to hear everyone's advice on does / don'ts / and how-to and how far back can I go for maximum inclusion. Thanks!

-Jeff

+3  A: 

Have you checked the prerequisites on the installer project? (Right click -> properties; Prerequesites button).

On the test project I created, the .Net framework is selected by default (I assume it doesn't actually analyse the projects being installed, as it doesn't include the C++ runtime libraries by default, either)

Rowland Shaw
Thanks for the reply. The pre-requisites on the installer project indeed includes .Net Framework 3.5 SP1. However, if I remove this then I will get the "wrong framework" error when they run the program. ChrisF's reply I think is my problem, that when I created the project I defaulted to .Net 3.5 as the targeted framework.. and for some reason this can not be changed in c++ after creation.
Which template did you create the application as? Is it using any of the /clr (or similar) switches? Have you tried using depnds.exe to determine the actual dependencies?
Rowland Shaw
I used "Win32 project" template and then in the project setup wizard selected "empty project".The compiler switches are"/O2 /Oi /GL /D "_MBCS" /FD /EHsc /MD /Gy /Fo"Release\\" /Fd"Release\vc90.pdb" /W3 /nologo /c /Zi /TP /errorReport:prompt"of which I do not believe any are related to common language runtime.I am setting up the depends.exe now (guess it was not a default install, have to specify it under custom install of visual studio) and will look into that. Thanks - Jeff
I'm not convinced that that would require the framework, and am still suspicious of the deployment project. I'm more than happy to be proven wrong though
Rowland Shaw
+2  A: 

In VS 2008 the default target framework is .NET 3.5.

For C++ on the Common Properties page there's a "Targeted Framework" drop down, but on the test project I created it's greyed out, so it looks like this can't be changed after the project has been created.

I created a second C++ project and selected the 2.0 Template from the New Project dialog and that had 2.0 in the "Targeted Framework".

So if you want to target a lower version of the framework it looks like you've got to create your project correctly in the first place.

EDIT: As to which version of the framework you should target - it all depends(!)

Do you need to use any of the 3.0 or 3.5 features? If not then go for 2.0. If you do then select that one and take the hit of the download. I can't say how likely it is that any class of user will have a particular version installed. As time goes on it will be increasingly likely that they will have 3.5 installed as other apps will require it.

ChrisF
Ok, I see this now. Thanks. Unfortunately is is greyed out, so I guess I will start a new project and copy everything in. All of my users will have windows XP professional, does anyone offhand know what target framework I should go for?
Re which version: I actually don't need .NET features (that I know of - it is win32 api code), but visual studio 2008 limits me to choosing .NET 2.0, 3.0, or 3.5. So I will go for the oldest, 2.0, hoping that either windows XP professional, Microsoft office 2003, or internet explorer 6 (on all the target user's pcs) carry at least 2.0. If not, those users can download the update. Thanks again!
Can you accept this ;)
ChrisF
Yes, this is acceptable. More and more I come across these gotchas that make me believe microsoft doesn't want me to use c++ in VS 2008 ;) examples:- intellisense works great for c#, not so for c++- click once deployment an option for everything but c++.. I imagine this one has legit reasons- ... but why in the heck can I not change the target framework after the start of a c++ project!?!?
No I meant accept it as the right answer ;) As to why you can't change the target framework - that's one for Microsoft. It looks like they planned it (it's a greyed out drop down on the properties).
ChrisF
The thing that confuses me is that there is no mention of any framework in the compile or linker flags, which is why I remain unconvinced that this is the cause...
Rowland Shaw
A: 

Well for C# projects, if you right click the Project file in Solution Explorer, and go to Properties, You can change the Target Framework on the "Application" tab. Is there something similar in the C++ Project Properties

Eoin Campbell