Error : Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

Hello All

I have created list in my SharePoint Site. And my requirement is to get data from SharePoint Site.

Here is my Simple code:

using (SPSite site = new SPSite(siteurl))
{
using (SPWeb web = site.OpenWeb())
{
SPList lstUsers = web.Lists["SiteUsers"];
SPQuery Qry = new SPQuery();
Qry.Query = "<Where><Eq><FieldRef Name='IsActive' /><Value Type='Boolean'>0</Value></Eq></Where>";
DataTable dtUsers = lstUsers.GetItems(Qry).GetDataTable();
if (dtUsers != null && dtUsers.Rows.Count > 0)
{
//Bind the data
}
}
}
}


When I am trying to get data from the SharePoint List, I got this Error Message:

Error : ‘Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack’

After doing some research I found solution. I need to change the Authentication mode in configuration file from ‘Form’ to ‘Windows’.

Solution : <authentication mode="Forms"> replace with <authentication mode="Windows">

That’s it, Problem Solved.
It works fine for me, Hope it helps

No comments: