Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Has anybody else had problems with Excel Services in SP2010? I am trying to programmatically access Excel web services. To connect to Excel services, I am direct linking to the Microsoft.Office.Excel.Server.WebServices.dll. The code I am using looks something like this:

Status[] status;
ExcelService service = new ExcelService();
string id = service.OpenWorkbook("http://server/ExcelDocLib/MyDoc.xlsx", "en-US", "en-US", out status);

The call to OpenWorkbook always works on the first request, but then throws an exception on all subsequent requests. The exception states "Safe handle has been closed". Here is the callstack:

   at System.StubHelpers.StubHelpers.SafeHandleC2NHelper(Object pThis, IntPtr pCleanupWorkList)
   at Microsoft.Win32.Win32Native.GetTokenInformation(SafeTokenHandle TokenHandle, UInt32 TokenInformationClass, SafeLocalAllocHandle TokenInformation, UInt32 TokenInformationLength, UInt32& ReturnLength)
   at System.Security.Principal.WindowsIdentity.GetTokenInformation(SafeTokenHandle tokenHandle, TokenInformationClass tokenInformationClass, UInt32& dwLength)
   at System.Security.Principal.WindowsIdentity.get_User()
   at System.Security.Principal.WindowsIdentity.GetName()
   at System.Security.Principal.WindowsIdentity.get_Name()
   at Microsoft.Office.Excel.Server.WebServices.ApiShared.ExecuteServerSessionMethod(Boolean hasSessionId, String sessionId, CoreServerSessionMethod coreWebMethod, String name)
   at Microsoft.Office.Excel.Server.WebServices.ExcelService.OpenWorkbookInternal(String workbookPath, Boolean editingMode, String uiCultureName, String dataCultureName, Boolean newWorkbook, Status[]& status)
   at Microsoft.Office.Excel.Server.WebServices.ExcelService.OpenWorkbook(String workbookPath, String uiCultureName, String dataCultureName, Status[]& status)
   at ExcelSessionConnection.Open()

From what I've seen on other forums, it sounds like this may have something to do with IIS 7 running in integrated mode, which is a requirement for SharePoint 2010. This exact same code works fine running under SharePoint 2007 with IIS in classic mode. I would appreciate any advice.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

In case anyone else is experiencing this problem, and comes here looking for a solution, I did get a response on another forum:

http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/ced022d8-9511-48ad-b7cc-76336bef68e2/#f3122c11-e06b-4131-8865-548ee666b2de.

As of this writing, the proposed solution is only a workaround for what is apparently a known issue to the Excel Services team, and they are currently investigating it. I hope this helps someone.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.