2

I have written a custom session state provider which works fine in debug mode but once deployed on the server (IIS 6) i get the following error:

Event code: 3008 
Event message: A configuration error has occurred. 
Event time: 10/7/2011 3:05:02 PM 
Event time (UTC): 10/7/2011 9:35:02 AM 
Event ID: 00e2c8b1368b45608bb062eb2ba9d0db 
Event sequence: 2 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/1/Root/bizapp-1-129624536989844520 
    Trust level: Full 
    Application Virtual Path: ...
    Application Path: ...
    Machine name: ...

Process information: 
    Process ID: 7556 
    Process name: w3wp.exe 
    Account name: ...

Exception information: 
    Exception type: ConfigurationErrorsException 
    Exception message: Object reference not set to an instance of an object. (E:\Program Files\BizAPP\WebClient\web.config line 282) 

Request information: 
    Request URL: http://localhost:8080/bizapp/login.aspx 
    Request path: /bizapp/login.aspx 
    User host address: 127.0.0.1 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: ...

Thread information: 
    Thread ID: 1 
    Thread account name: ...
    Is impersonating: False 
    Stack trace:    at System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType)
   at System.Web.SessionState.SessionStateModule.InitCustomStore(SessionStateSection config)
   at System.Web.SessionState.SessionStateModule.InitModuleFromConfig(HttpApplication app, SessionStateSection config)
   at System.Web.SessionState.SessionStateModule.Init(HttpApplication app)
   at System.Web.HttpApplication.InitModulesCommon()
   at System.Web.HttpApplication.InitModules()
   at System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers)
   at System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context)
   at System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context)
   at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)

EDIT line 282 is from web.config having the provider info, 3rd line below

<sessionState mode="Custom" customProvider="SessionStateStoreProvider" timeout="180">
            <providers>
                <add name="SessionStateStoreProvider" type="type full name" />
            </providers>
        </sessionState>
Kiquenet
  • 14,494
  • 35
  • 148
  • 243
Vinay B R
  • 8,089
  • 2
  • 30
  • 45

2 Answers2

1

It means the "Object reference not set to an instance of an object" exception happens in one of your provider's methods (for example in the Initialize method). There's a bug in that code.

So you can either put a breakpoint in there and debug, or surround overridden methods with a try catch that can transform the exception in text, like this:

public class YourSessionState : SessionStateStoreProviderBase
{
    public override void Initialize(string name, NameValueCollection config)
    {
        try
        {
            // your original Initialize code here
        }
        catch (Exception e)
        {
            throw new Exception("Error in initialize: " + e);
        }
    }
}

If you put the .PDB files aside the .DLL, you should now see the error line number.

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
  • Thnx for pointing me in the right direction Simon, the error was not really in the initialize method but in GetItemExclusive.wat i dont understand is y it could not have included this info in the stack trace. – Vinay B R Oct 12 '11 at 12:18
  • @VinayBR - I Agree, Microsoft should definitely change the way they handle exceptions in the providers. It's quite hard to determine the cause of a problem in production w/o the full stack traces. I have also updated my answer to reflect your comment. – Simon Mourier Oct 12 '11 at 13:12
-1

You're not specifying the type correctly in your configuration.

Example:

<sessionState mode="Custom" customProvider="SessionStateStoreProvider">
  <providers>
    <add name="SessionStateStoreProvider"
         type="Namespace.To.Your.SessionStateStoreClass" />
  </providers>
</sessionState>

Unless you intentionally omitted the type.

Denny Ferrassoli
  • 1,763
  • 3
  • 21
  • 40