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.