Get VS to highlight all .Net 3.5 SP1 method calls - c#

There are a bunch of new APIs in .Net 3.5 SP1.
Short of uninstalling .Net 3.5 SP1 (or doing dev on a VM), is there a way I can get VS 2008 to target .Net 3.5(RC) as opposed to .Net 3.5 SP1?
Is there a way I can get it to issue a warning when there is an API not supported in 3.5 SP1 which is being invoked?
Similar question: Find code that depends on .NET 3.5 SP1

This actually has a surprisingly tricky answer.
First of all, to get this functionality that is outline in the following post you will need either the latest version of fxcop or VS 2008 SP1.
Once you have that installed there is a new rule (in VS 2008 Team System) called Portability Rules -> Use only API from targeted framework.
But that is not enough
Fxcop is currently shipping with dodgy wpf rules:
Quote from the last line in the above post:
It seems like there are bugs in this
because it didn't complain when I
referenced IEditableCollectionView
which was added in 3.5 SP1. As a
matter of fact, it seems like
"C:\Program Files\Microsoft Visual
Studio 9.0\Team Tools\Static Analysis
Tools\FxCop\Repository\Compatibility\Desktop3.5SP1.xml"
doesn't list ANY of the new WPF
assembly members.
Andrew, thanks for the feedback. You
are correct, there is a bug. The data
for WPF 3.5 SP1 is included, it's just
listed under 3.0 SP2. However, the
'Priority' attribute for this file and
2.0 SP2 is incorrect. I've forwarded this information on to my old team, in
meantime, a workaround is to manually
change these files; for
Desktop3.0SP2.xml change the priority
from '3020' to '3520' and for
Desktop2.0SP2.xml change the priority
from '3015' to '3515'.
So you will need to crack open cmd in admin and fix up those files if you want this to work.
Once that is done, it seems to work fine.

Related

How do I compile a simple WinForms C# application for .NET Framework 2.0 in Visual Studio 2005 or 2019?

I need to create a very simple WinForms C# application that only requires .NET Framework 2.0 to execute properly (due to the fact that the customer isn't allowed to upgrade or connect his computer to the Internet).
On my computer I have Visual Studio (VS) 2005 and VS2019 installed.
I first tried VS2005 and created an empty WinForms application and sprinkled the project file with <TargetFrameworkVersion>v2.0</TargetFrameworkVersion> tags and compiled.
I then checked the .exe-file inside JetBrains dotPeek (according to a tip I found on How to find out which version of the .NET Framework an executable needs to run?) but it says it's .NET 3.5 application.
I then tried with VS2019, but I didn't have to manipulate the project file manually, instead I used the user-friendly dropdown for selecting target framework and set it to 2.0. However, the result was the same, the application became a .NET 3.5 application.
Does anybody know what I'm doing wrong?
The problem appears to be that JetBrains dotPeek is not reliable. I tried an .exe-file that JetBrains dotPeek reported was using .NET Framework 3.5, but I had no problems executing it on computer with only Windows 2000 and .NET Framework 2.0 installed. I agree with this answer How to find out which version of the .NET Framework an executable needs to run? that it's better to inspect the .exe-file in Notepad to determine which .NET version it requires.

how to open and compile .net 4.5 winform app in visual studio 2008

I have developed a program in visual studio 2012, my targeting framework was 4.5 and now i want it to be open in vs 2008.
I tried to edit cs file in notepad and edited it, but could not compile.
Is there any workaround?
Any help will be highly appreciated.
Visual Studio 2008 doesn't support the .NET 4.5 Framework. The maximum it supports is 3.5.
Similarly, the maximum VS 2010 supports is .NET 4.0.
You can try changing the target framework to 3.5 before opening it in VS2008, but if you're using anything from the newer frameworks, it won't compile.
Additionally, here's a Wikipedia article with the supported framework (and other information) for each Visual Studio release.
From ScottGu's blog: http://weblogs.asp.net/scottgu/archive/2009/08/27/multi-targeting-support-vs-2010-and-net-4-series.aspx
There isn't any way to target .NET 4 from VS08 and use new features.
Having said that, .NET4 is upwards comaptible with .NET 3.5 - so
applications you build targeting .NET 3.5 with VS08 should work fine
on top of .NET 4.
So in simple words you just can not!
Are you actually using features from the 4.5 framework? There's no IDE-supported way to do this, as other answerers have pointed out. What you can do is this:
Create a new project in Visual Studio 2008.
Add your files to it.
Go through and remove any references to .NET 4.5 and ensure it builds cleanly under .NET 2.0 or whatever VS2008-compatible framework you're targeting.
Rinse and repeat until you get a clean build.
Depending on what you're actually using in code, this may entail a lot of work or very little.

Where does the .NET framework come from? Visual Studio or Windows?

I am learning C# and have installed Visual Studio 2012 on a PC running Windows 7.
I can now browse to the C:\Windows\Microsoft.NET directory.
My first question is:
Does Visual Studio ship with the .NET directory, or does Visual Studio just access the directory that already exists on a computer running Windows 7?
My second related question is:
The highest numbered folder at the location C:\Windows\Microsoft.NET\Framework\ is v4.0.30319. This confuses me because the version number associated with Visual Studio 2012 in the table at https://en.wikipedia.org/wiki/.NET_Framework#History is 4.5.50709.17929.
So why do I not have a folder with that higher version number if I installed Visual Studio a couple of weeks ago?
Windows 7 comes with .NET 3.5 SP1. Visual Studio does not ship with .NET.. however, .NET ships with Visual Studio (obviously, so you can develop on it).
The version number didn't change between 4 and 4.5 .. I cannot remember the reason why (I think it had something to do with it being an in-place upgrade.. or something). This is why the folder version numbering is the same.
EDIT:
You can look here for a better explanation of the .NET 4/4.5 versioning and what the exact revision numbers mean: https://stackoverflow.com/a/12972517/1517578
Visual studio is just an IDE that requires the .NET framework. Lots of applications require the .NET framework so there's a chance that you could have had .NET installed before installing VS. Installing VS, however, will ensure you have the correct .NET runtime for your version.
.NET 4.5 is an in place replacement to the .NET 4.0 framework so the folder will still be called v4.0.... I guess this is a way to avoid problems with systems built on .NET 4.0
There is a good article here about .NET 4.0 and .NET 4.5
Visual Studio ships with the .NET directory and it also accesses the directory if that already exists. One can install .Net 4.5 separately too
The highest numbered folder v4.0.30319 is the version of the CLR and not the .Net Libraries. .Net v4.5 replaces v4.0 similar to the way v3.0, v3.5 and v3.5SP1 replace v2.0 still the CLR version remains v2.0.xxxxx. This is the reason why you don't have a folder with higher version number.
It comes with windows os. If you go to Turn Windows features on or off you will see the Microsoft .NET framework

Making sure C# program can run on machine with only .Net v2

I'm using VS 2005 Standard SP1, with .Net 3.5 SP1 installed on XP.
The client machines only have .Net 2.0.50727 installed (also on XP).
How can I tell the compiler to reject any classes or methods that are not available in .Net 2?
In Visual Studio 2005 this is not possible because it simply doesn't know about .Net 3.5. Visual Studio 2008 is the first version which understands .Net 3.5.
The best way to make sure you don't use any classes defined in 3.5 is to do the following
Don't reference any DLL's from 3.5 (System.Core,System.Xml.Linq,etc ...)
Run the FxCop rule which spots for 3.5 violations in 2.0 projects. This was initially added to Visual Studio 2008 but I don't see a reason you couldn't use it in a 2005 project if you installed the latest FxCop
Here is a link to a blog article about the FxCop rule I was talking about.
http://blogs.msdn.com/kcwalina/archive/2007/10/02/Multi_2D00_TargetingAndFxCop.aspx
The article does talk about running it against VS2008. But I don't immediately see a reason it couldn't be used in VS2005. But I don't have an install handy to test it on.

Can I write an app in the new version of Visual Studio and make it compatible with .NET Framework 1.1

I am a Web developer who spends 99% of his time in Linux, but I need to develop a super simple application with VB or possibly C# (.Net). The only version of Visual Studio I have is the most current free ones. There MIGHT be a copy of 2001 lying around somewhere. Anyways, the machine I need to develop this for is running Windows NT4. I cannot change this because another piece of software runs on that requires it.
Is there a way to develop an app with the new VS and keep it compatible with such an old version of the .Net framework (1.1)?
If nothing else I could install Perl on the machine and write a command line type script, but given the people that will be using it GUI would be better.
I don't believe you can target .Net 1.1 in Visual Studio 2008. Here's one of the developer's explanations, from a comment in this blog entry:
Visual Studio 2008 will not support targeting .Net Framework 1.1. This is something we really wanted to be able to support - since we know there are a lot of .NET developers working on .NET 1.1 applications. However, it would have been significantly more difficult to go back and support .NET 1.1 which was a substantially different runtime.
Thus, to fit in this release, the
decision ended up being either to not
support multitargeting at all - or to
support only targeting .NET2.0 and
greater. Because we really wanted
Visual Studio 2008 to be a great tool
for at least both .NET 3.0 and .NET
3.5 - we decided to put in the most multitargeting support we could fit in
this release.
Have you tried MSBee? This is an add-on to VS2005 (well, strictly speaking: MSBuild in 2.0), but it may well work with VS2008 too. Of course, you can always use the IDE to write code, and simply use MSBuild from the 2.0 folder to build...
Either way, if you target .NET 1.1, you can only use .NET 1.1 / C# 1.2 features.
Personally, I'd target 3.5SP1, using (if it needs to be free) C# Express 2008. (I've removed this since you need to target such an old OS)
You can use vs.net 2008 to write code that is able to run on .net v1.1 but the IDE won't give you any hints on what will work etc.
You will be stuck using inline asp.net for a model.
(or compile using the commandline tools)
There are a lot of examples using this method here:
http://www.learnasp.com/freebook/learn/
This code is all v1.1 except for the explicit naming of the v2 examples.

Categories

Resources