Click here to Skip to main content
15,843,623 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Requirement: We need to show user profile data along with their(user’s) MySite url details.
For this there is a sharepoint method called “GetUsageData”.
We used that method and getting all the required details.

What I did is, I have created a commonclass and put all the userprofile reading logic including MySite URL details and putting those details into an excel file in a custom method.

Process: In a separate solution, I included the above class dll as a reference.
I am instancing the above commonclass and calling the custom method.
The problem is when I debug the code in common class method, an exception is raising at “GetUsageData” sharepoint method.
The exception is “UNABLE TO EVALUATE THE EXPRESSION BECAUSE THE CODE IS OPTIMIZED OR A NATIVE FRAME IS ON TOP OF THE CALL STACK”.

I put all my logic under RunWithElevatedPrivileges method.
I tried in google to solve this, but I did not get the exact solution, but when I put all the custom method which is there in common class into my local solution, it is working fine.

Do you have any idea what the exception or what can be the cause of that exception. Below is the code I have written and getting exception at RED color line.

C#
using (personalSite = new SPSite(mySiteUrl))
{
            using (SPWeb usageDataWeb = personalSite.OpenWeb())
            {
DataTable usageDataTable = usageDataWeb.GetUsageData(Microsoft.SharePoint.Administration.SPUsageReportType.user, Microsoft.SharePoint.Administration.SPUsagePeriodType.lastMonth, 15, DateTime.Now);
                        excelReportCell = new Cell();
                        excelReportCell.DataType = CellValues.String;
                        excelReportCell.CellReference = "E" + cellCounter.ToString();
                        if (usageDataWeb != null)
                        {
                              excelReportCell.CellValue = new CellValue(usageDataWeb.Created.ToShortDateString());
                        }
                        else
                        {
                              excelReportCell.CellValue = new CellValue("");
}
                        excelReportCell.StyleIndex = 9;
                        excelReportRow.Append(excelReportCell);
}
}

Please refer the below, which is my exact problem.
http://blogs.devhorizon.com/reza/?p=472[^]

[edit]Tags and subject only - OriginalGriff[/edit]
Posted
Updated 6-Feb-11 22:52pm
v4
Comments
Dalek Dave 7-Feb-11 3:52am    
Edited for Readability.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900