I have the following code in a windows form application to access a SharePoint list. I have full access to the site collection and the list. However, I got "-1073741819 (0xc0000005) 'Access violation' error when the code tried to access the list. I have tried it with different list and got the same result.
using (SPSite oSPsite = new SPSite("http://localhost/"))
{
using (SPWeb oSPWeb = oSPsite.OpenWeb())
{
SPList aList = oSPWeb.GetList("BTU");
…
}
}
Please advise if you know what is my problem. Many thanks.