Visual Studio 2010 managed c++ targets .NET 2.0 PROBLEM - visual-studio-2010

For someone who's been down this road, please share your breadcrumbs.
I have old VS2005 solution. Most of the parts are c# but I have one c++ managed project. Dev machine: Windows XP. Target framework version: 2.0
I moved the project to the Windows 7 64 BIT, VS 2010, did the project conversion. First thing I noticed were build errors - projects depending on one what is in c++ complained that project referenced has target 4.0 and I want to use it in project that (properly) targets 2.0.
OK, so I used some tips and set my project target to .NET 2.0. NOW: VS2010 complains that it cannot load the project because I need to install framework 2.0. OK, so I try to install it, and nothing - since installer detects .NET 2.0 as a part of the operating system.
WTF?
Admins, please create WTF tag for me here :)

It is not the .NET version that's the problem. The C++ build system currently does not directly support building for pre-.NET 4.0 targets. It requires VS2008 to be installed so it can use its tool chain. Sounds like you don't have it.
This blog post explains the workaround. You can upvote this feedback article if you're unhappy with that. No idea if this is slated to be fixed in SP1, this is not drawing a lot of votes.

Related

VS 2019 Project Target Framework Not Installed - .Net Framework 4.0

Just installed VS 2019 Pro on a new system. When I open a solution with .net 4.0 project, I get this error: Project Target Framework Not Installed.
When I choose download it, it goes here but does not have option for .net framework 4.0.
In project settings there is no option for .Net Framework 4.0 in targeting framework:
https://dotnet.microsoft.com/en-us/download/visual-studio-sdks?cid=getdotnetsdk
I have tried installing 4.6.2, 4.5.2, etc.
How can I get this project to open? It opens on my other machine. It has these options for Target framework in project settings:
Please don't say change the framework version, we need this older version for very old computers running XP and Win 7 that cannot be upgraded.
thank you
You have to go directly to their download site. As shown in another correct answer that was downvoted, it's still available even though it's past end-of-life.
https://stackoverflow.com/a/72870727/9008140
You can package the install files with your app just in case, although most likely your installer will see that it's missing and download it anyway.
You can try downloading .Net 4.0 here: https://dotnet.microsoft.com/en-us/download/dotnet-framework/net40
Mandatory warning: Installing an old, unmaintained .Net framework comes with security risks. It's up to you to determine how much those Windows XP PCs are vulnerable and manage said risks.

How MSBuild multitargeting works

I will try to explain this as clear as I can
I want to fully understand how MSBuild multitargeting works.
I have read several articles from Microsoft and I think I understand the basic but I want to be sure I am not missing anything.
According to Microsoft:
By using Visual Studio, you can compile an application to run on any one of several versions of the .NET Framework. For example, you can compile an application to run on the .NET Framework version 2.0, and compile the same application to run on the .NET Framework version 4. The ability to compile to more than one framework is named multitargeting.
Visual Studio runs under the most current version of the .NET Framework that is installed on the development computer.
http://msdn.microsoft.com/en-us/library/ee395432.aspx
So do this mean that Visual Studio always calls MSBuild from the latest framework installed? assuming Visual Studio 2010 is installed, it will always call: %WINDIR%\Microsoft.NET\Framework\v4.0.30319\MsBuild.exe when building any project targettting any .Net Framework version right???
If yes, then the ability to target old .Net Framewrok versions is based on the ToolsVersion and/or TargetFrameworkVersion properties right???
If yes again, it would mean that just installing the latest framework (and also the older frameworks but not installing visual studio) in my Continuous Integration box, I could point to build always any solution to: %WINDIR%\Microsoft.NET\Framework\v4.0.30319\MsBuild.exe and just specify the ToolsVersion argument (if required, since each project can have its own target version specified in the TargetFrameworkVersion which it would cause to target an older .Net Framework version).
Following this I think my CI box would be building like Visual Studio does. Am I right? What am I missing? Is there a way to be completely sure?
I did a quick test, and I think it works :p the projects are being built according to the .Net Framework specified but like I said I want to be sure I am not missing anything.
Any thoughts?
BTW:
The simple reason to want to do that is because I have several custom MSBuild scripts that are reusable accross projects, but some of the functionality in these scripts require MSBuild 4.0 and also I have several MSBuild tasks built on top of the framework 4.0 so if I have for example a solution targetting the Framework 2.0 and I try to build it using: %WINDIR%\Microsoft.NET\Framework\v2.0.50727\MsBuild.exe I get MSBuild errors trying to load my custom targets
Yes, you've got it mostly correct. Calling MSBuild from the 4.0 directory will do the correct thing against previous versions. They only thing I wanted to add was that 3.5 must be on the box to actually build projects targeting 2.0, 3.0 and 3.5.
This page here: http://msdn.microsoft.com/en-us/library/bb822049.aspx calls out the what versions Windows comes with what version of the framework pre-installed.

Visual Studio v2003, v2005, v2008 and v2010 existing on the same system

I currently have Visual Studio v2003, v2005, v2008 installed on my system. Things work fine...no issues.
I now have to install Visual Studio 2010 on my system and just wanted to know if anyone has a setup like mine or knows if there are any potential issues with so many versions existing on a system.
Really don't have a choice to remove older versions as we have a lot of legacy products written in these old versions and we are not upgrading them to new versions, only doing bug fixes on them.
Any ideas?
Thanks!
VS2010 supports targeting on multiple versions of .NET Framework (i.e. 2.0 or later), which mean it is designed to support the projects that were built with VS2005/VS2008 so-called backward-compatibility.
So I think no conflict here between these versions,
I've found a nice Myths and facts about VS 2005/2008/2010, check out this link here: http://msdn.microsoft.com/en-gb/ee679805.aspx
It should work.
I have vs2003, vs2008 and vs2010 installed and I see no issue (but vs2010 is not yet used for production code).
M.
All these versions of Visual Studio are independent.
You should have no problem (other than lack of disk space!) installing VS2010 as well.
Just make sure you install the service pack as well.
They cohabitate fine, I have a similar setup myself.
You should at least push for migrating away from 2003 and 2005 though, they use some pretty old technology, and pretty much everyone these days has .net 3.5 on their systems.
If you are able to use VS 2010 I would highly recommend you do for all new projects - even if you have to target an earlier version of .NET framework.
Keep the old versions of VS installed only for maintenance of projects that cannot be migrated to VS 2010 version.
By the way, the migration to VS 2010 is often very trivial and well worth an hour or two of effort!

Windows CE project with libraries problem

I am developing a Windows CE application which uses some libraries provided by other parts of our company.
When I deploy my application on "My Computer" (.NET compact application running on standard PC), everything works, but when I deploy to the device, the application hangs when trying to use methods from the library. The system also hangs. My Visual Studio 2008 sometime hangs, but sometime throws an exception "TypeLoadException: Could not load type from assembly Culture=neutral, PublicKeyToken=nu".
I couldn't include .NET Compact framework 3.5 because the image wouldn't compile, so I am using version 2.0. I use Visual Studio 2008 with deploy .NET framework option.
Most probably the problem is with version of the library you are using. Please cross check it.
Hope this link will help you.
I'm a bit confused.
First of all, what are the libraries "provided by other parts of [y]our company" build against? Are they Compact Framework assemblies (they must be)? What version of the Framework were they build against? Reflector can tell you this if you don't know.
Second, why can't you compile it with 3.5? What sort of errors are you seeing? The code should be 100% forward compatible, so if it won't build, there's a red flag going up.
Lastly, what version of the CF is installed on the target hardware? FOr example, are you trying to push a CF 2.0 app to a device with CF 3.5 already installed? If so, do you have an app.config file that provides the framework compatibility options so it knows it can run your assembly?
The problem was that libraries were compiled with for 3.5 target framework, and the application which uses them form 2.0 framework. In that case, 3.5 framework wasn't depoloyed and application would stop working as soon as call to the library methods was made.

.Net Framework 3.5 is needed for installing my VB 2008 Project?

Using VS 2008
I created a setup file for my Project, I run the setup file in my system, and My Project is working fine.
If I install my project to another system, is asking .Net Framework 3.5 at the setup time.
.Net Framework 3.5 is needed for installing my Project?
Before i installing my project, i install the .net framework 3.5, It taking to much time to setup?
How to solve this? or any other way to create a Project setup ?
Can any one help to solve my setup problem.
What you need to do is right click on the setup project in the SolutionExplorer and select the Properties menu option. You can then click on the Prerequisites button. This allows you to control what your setup program needs/wants in order to install your code.
If you don't need .NET 3.5 then just unselect it. This is just one more annoying thing that VS2008 does, you select .NET 2.0 as your target framework but it leaves .NET 3.5 as a pre-req.
If it is important for you that your program does ot require .NET 3.5, you can set up your project to target .NET 2.0. The the setup project will also see this, and (hopefully) remove the dependency when you update it.
If your project is VB.NET, you can set the Target Framework version here:
Project Properties -> Compile -> Advanced Compile Options...
If Your project is C#, it is here:
Project Properties -> Application
If you do this, of course you will not have available any .NET 3 specific functionality.
Do you rely on .net 35 features in your code. If not you can recompile with the project settings targetting .net 3.0 or 2.0.
The .NET 3.5 framework has two different installers to choose from: the bootstrapper and the full package.
The bootstrapper installer is small in size (2.7 MB). It's small because it downloads the required files from the internet when executed on the target machine. Depending upon the target's network bandwidth, it may take a long time to run.
The full package installer is large (237 MB), and does not require an internet connection to run.
If you are currently using the bootstrapper installer, you should try downloading the full package installer and running that on the target machines.
(That is, if you actually need .NET 3.5)
You can select either installer from here.

Resources