locked
VS2010, solution pointing at ASPNet4.0 website, odd seemingly inaccurate compile error RRS feed

  • Question

  • User1562156107 posted

    Hi...

    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?

    Thanks

    Mark

    Friday, February 8, 2013 5:58 PM

Answers

  • User1562156107 posted

    Finally decided to dig into this more, and I found this on StackOverflow:

    http://stackoverflow.com/questions/5567945/type-or-namespace-name-does-not-exist

    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 to work.

    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).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 7, 2014 3:37 PM

All replies

  • User1562156107 posted

    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.

    Thanks

    Mark

    Monday, February 11, 2013 12:49 PM
  • User1562156107 posted

    Finally decided to dig into this more, and I found this on StackOverflow:

    http://stackoverflow.com/questions/5567945/type-or-namespace-name-does-not-exist

    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 to work.

    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).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, January 7, 2014 3:37 PM