I know this is a common problem and there are lots of suggestions on the internet, but non of them helped me to sort this issue out.
I have created my data context class by using SPMetal.exe tool.
I have created a console application with the configuration below
CPU: Any CPU Framework: .net 3.5
I tried to test whether my datacontext is working fine or now via the lines below,
IMG.CustomerPortal.Data.Context.IMGContextDataContext con = new IMG.CustomerPortal.Data.Context.IMGContextDataContext("http://server/site_name/");
EntityList<TicketItem> lst = con.GetList<TicketItem>("ListName");
Console.WriteLine(lst.First().ClosedDate);
Console.ReadKey();
it throws an error below;
The Web application at http://server/site_name/ could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
However, in same project, I am able to access to the data via client object model by using the code below;
string siteUrl = "http://server/site_name/";
ClientContext clientContext = new ClientContext(siteUrl);
Web oWebsite = clientContext.Web;
ListCollection collList = oWebsite.Lists;
clientContext.Load(collList);
clientContext.ExecuteQuery();
foreach (var oList in collList)
{
Console.WriteLine("Title: {0} Created: {1}", oList.Title, oList.Created.ToString());
}
Console.ReadKey();
Is there anything I am doing wrong here? it does not seem to be related to framework version or architecture.
is there anything missing, or any idea why it throws this?
Thanks