File Not Found Error with SharePoint 2010 and Visual Studio 2010

Hey folks, I've had this happen to me a couple of times and it's driven me a little crazy figuring out what was going on.  You may use Visual Studio 2010 to create a new SharePoint 2010 application.  You do something innocuous like using (SPSite theSite = new SPSite(myUrl)) and when the code executes, you get the dreaded "file not found" exception.  So what's going on?  Well what I've seen happen to myself and a few others, is that VS 2010 is targeting the .NET Framework 4.0 by default.  SharePoint 2010 is using the .NET Framework 3.5.  So the first step is you go in and change the version of the framework you are targeting to 3.5.  You go and run your app again and what happens?  Same error.  Well the problem it appears is that when you change the target framework version, it also changes the target CPU from Any CPU to x86.  Of course, SharePoint 2010 is only x64, so of course when your x86 app tries to load an x64 assembly, it fails and and in really weird way the file not found exception then makes sense.  Okay, that's kind of apologistic but you get the gist.  So step 2 here is obviously to go back and change your target CPU back to Any CPU and you should be good.  That has fixed the problem a number of times for different people now - hope it helps you too.

Comments (4)
  1. alexandrad9x says:

  2. Surendra says:

    I got the same problem

    Any CPU, v3.5

    Still same problem……Any Help

  3. SDF says:

  4. m88 says:

    One of the most notable highlights during the super classic 7th M88 last night’s debut of striker Luis Suarez shirt in Barcelona, and was also the re-export of these players received suspended sentences after 4 months spring.

    Although the origin of Catalunya giants failed to lead 1-3, but Suarez himself had a match is not bad. He set up a goal for Neymar opened the scoring in the 4th minute right, moves actively, supports the new M88 team. Even if Lionel Messi advantage delicious
    street food "like moving deck" Suarez from the right after 23 minutes, can be super classic confrontation turn into another direction.

    After the game, press Uruguay – Luis Suarez homeland in the dissection causes giant Catalunya origin point loss in the Bernabeu. Most communication facility M88 South American country have expressed surprise that witnessed the darling players off the pitch
    at the beginning, in a game is more important.

Comments are closed.

Skip to main content