Last post Jan 07, 2014 03:37 PM by mmodrall
Feb 08, 2013 05:58 PM|mmodrall|LINK
I've got a VS2010 solution point at a website running under ASPNet 4.0. The code and the website run fine, but when I'm in VS and click Rebuild Solution, I get a spurious error message that flashes by "The type or namespace var could not be found."
Now, I do have a statement
var x = webService.GetData();
in my C# code, but that's legal with any framework > 2...
Aspnet_compiler builds the code without any complaints. I'm just wondering why VS is throwing this spurious exception... Any ideas?
Feb 11, 2013 12:49 PM|mmodrall|LINK
A few more things...
When I use Build Web Site, the compiler errors about the var usage don't flash by; they stay on the screen and it says Build failed. When I use Rebuild Web Site, the complaints flash by and then disappear.
Interestingly, Rebuild also produces a warning that Build does not:
The following assembly has dependencies on a version of the .NET Framework that is higher than the target and might not load correctly during runtime causing a failure: AjaxControlToolkit...
We had a very old version of AjaxControlToolkit, so I tried updating it. The last several releases have a very long list of version mismatches.
Jan 07, 2014 03:37 PM|mmodrall|LINK
Finally decided to dig into this more, and I found this on StackOverflow:
Fourth answer down, from John West, did the trick.
I had VS convert the solution up from a VS2005 one, then I edited the solution file to add the target version attribute for v4.0. For obscure reasons I started getting the compiler errors reported here.
It's probably something getting stored in the .suo or .user files somewhere, but apparently just jumping to v4.0 wasn't good enough. You have to go in the VS ui and incrementally raise the target version setting until you get to the top for the builds
I set it back to v3.5 and did a build, whereupon my Linq statements started compiling but my 4.0-specific statements still blew up. Then I set it up to v4.0 again, and everything builds fine now.
The net .sln file doesn't change, and yet compilation starts working (hence the theory that it's something in the local user files that gets corrected).