Wednesday, December 9, 2009

Session state is corrupted

If you got some error like that – the problem is in your TV, not in IIS, not in Sharepoint :-))

Exception message: The session state information is invalid and might be corrupted.

Stack trace:    at System.Web.SessionState.SessionStateItemCollection.Deserialize(BinaryReader reader)
   at System.Web.SessionState.SessionStateUtility.Deserialize(HttpContext context, Stream stream)
   at System.Web.SessionState.SqlSessionStateStore.DoGet(HttpContext context, String id, Boolean getExclusive, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actionFlags)
   at System.Web.SessionState.SqlSessionStateStore.GetItemExclusive(HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actionFlags)
   at System.Web.SessionState.SessionStateModule.GetSessionStateItem()
   at System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData)
   at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

image

This occurs when there is a null value used for a Session Key and later a string based session key is used.

- Code adds a Null session key - this works and there are no errors.

- At a later request, code adds a string session key.

You are doing one of the following:

Object var = SomeFunction();

Session[var] = AnotherObject;

Or

Session[SomeFunction()] = AnotherObject;

You need to the return value and ensure it is not null!

Wednesday, December 2, 2009

Edit Document from MOSS 2007 with Office 2003

I had a case with customer (who uses Office 2003 ~4000 PCs and approximately 150 computers with Office 2007) where if the users try to open office document from MOSS 2007 with Office 2003, the file is always opened as read only. Our custom application needs to open the doc for edit and check it out. So, the result were – it is not supported by Office 2003.

What is supported and what not, is described here

Finally, after customization of CORE.JS we succeeded to run Office 2003 to work as 2007 and these steps are described below :)

In the beginning I need to say, that this blog post were very important, regarding the chosen technical approach

1. I created empty file in the following path: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\1033\Checkout.JS

2. I got the code of DispDocItemEx function from CORE.JS file (in the same folder) and paste it inside the new one

3. In Checkout.JS I modified the code:

Original:

================

else

    {

    fRet=stsOpen.ViewDocument2(window, szHref, szAppId);

    }

================

Modified:

================

    else

    {

    if (ctx.isForceCheckout==true)

    {

    fCheckoutForEdit=confirm(L_ConfirmCheckout_Text);

        if (fCheckoutForEdit==true)

        {

        CheckoutDocument(ctx.HttpRoot, szHref, null);

            fRet=stsOpen.EditDocument2(window, szHref, szAppId);

            }

       else

       fRet=stsOpen.ViewDocument2(window, szHref, szAppId);

    }

    else

    fRet=stsOpen.ViewDocument2(window, szHref, szAppId);

    }

==================

4. I created a copy of C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\GLOBAL\default.master with name custom.master

5. Added the following code just after the red line

<SharePoint:ScriptLink language="javascript" name="core.js" Defer="true" runat="server" />

<!-- Checkout JS customization BEGIN -->

<SharePoint:ScriptLink language="javascript" name="Checkout.js" Defer="true" runat="server" />

<!-- Checkout JS customization END –>

6. I uploaded custom.master into http://myportal/sites/mysitecollection/_catalogs/masterpage, published and approved the new file.

7. The next step were to configure the site to use customized master page

clip_image002

8. During the tests I found, that if I click on the file link (in document library page /AllItems.aspx) Office 2003 has the same behavior as Office 2007.

clip_image002

clip_image002[7]

The file is checked out, “Shared workspace” pane is opened and on document close the following windows appear

clip_image002[9]

But, here I want to make a note, that if you try to open a document in any other fashion (such hyper link in email or web page), the CheckIn-CheckOut menu items and/or TaskPane functionality may not be available or work as expected. This modification only affects the behavior of the document library page.