Just came to know about very basic stuff in SharePoint 2010. Let’s say you are creating one simple console application in VS 2010 that just displays your site name.
using System;
using Microsoft.SharePoint;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
using (SPSite objSiteColl = new SPSite("http://myurl"))
{
Console.WriteLine("Title of the site is : {0}", objSiteColl.RootWeb.Title);
}
Console.ReadLine();
}
}
}
And you run the code, you get System.IO.FileNotFound exception saying that web application is not found, verify that you have typed the correct URL. So what do we do now? We go back and check the URL,hum…URL is perfect, nothing wrong about this. So small program and still not able to run it?
Well, answer lies in VS 2010 because by default build property is set to x86 and SharePoint does not work on x86 platform. As we all know that now MS wants everyone to move on 64 bit PCs. (Another money eating machine), so go to project properties, go to build tab and change the platform target to x64 and try now.
There you go; I think your error might have gone now. What say?
4 comments:
What if You Select it as Any CPU
Thanks for the fix. I linked back to your article. Thanks paul
I have changed target platform to x64 but still facing the File not found exception
rajesh,
we think it should resolved.
check application log and SP log, you might find something over there.
Post a Comment