Object reference error during custom session state provider initialization
See the question and my original answer on StackOverflowIt 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.