Hi we have a problem while accessing MySite URL for a user profile in sharepoint.
We need to get details of MySite URL of a user using sharepoint "GetUsageData" method.
whenever we access this we are getting the exception as "Unable to evaluate the expression, because code is optimized or native code is on top of call stack".
For this I achived like below.
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPSite siteCollection = new SPSite("http://..")
SPUserToken token = siteColllection.SystemAccount.UserToken;
using(SPSite site = new SPSite(mySite,token)
{
using(SPWeb web = site.OpenWeb())
{
DataTable dt = web.GetUsageData(....);
}
}
});
Wednesday, February 9, 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment