Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6380201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:14:14+00:00 2026-05-25T02:14:14+00:00

I am using StructureMap to store a session object: config.For<SessionContext>().LifecycleIs(new HttpSessionLifecycle()); And everything works

  • 0

I am using StructureMap to store a session object:

config.For<SessionContext>().LifecycleIs(new HttpSessionLifecycle());

And everything works okay, so I can easy retrieve the session object with DI.

But now I need to switch my session from in-process to the database, but I receive the following error.

Unable to serialize the session state. In ‘StateServer’ and
‘SQLServer’ mode, ASP.NET will serialize the session state objects,
and as a result non-serializable objects or MarshalByRef objects are
not permitted. The same restriction applies if similar serialization
is done by the custom session state store in ‘Custom’ mode. —>
System.Runtime.Serialization.SerializationException: Type
‘StructureMap.Pipeline.MainObjectCache’ in Assembly ‘StructureMap,
Version=2.6.2.0, Culture=neutral, PublicKeyToken=e60ad81abae3c223’ is
not marked as serializable.

How can I solve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:14:15+00:00Added an answer on May 25, 2026 at 2:14 am

    The problem was in StructureMap. I’ve added the [Serializable] attribute to the MainObjectCache class and some others and tested it out. It works now. The fix can be found in this pull request.

    I hope @Joshua Flanagan will merge these changes into the master branch soon and the problem will be finally solved.

    Edit:

    Thanks, I’ve pulled in your change (and a few others) and pushed a
    2.6.3 release. Edit your answer to say it was a bug fixed in 2.6.3 and
    mark it as the accepted answer. – Joshua Flanagan

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Using StructureMap 2.5 to scan all assemblies in a folder , we can
I am using StructureMap on an ASP.NET MVC project. I have an object that
What is best pratices for inject and manage Session/Transaction for NHibernate using StructureMap for
Using StructureMap, is it possible to have a singleton object for each value of
I'm using StructureMap DI/IoC and I've got is a generic InMemory repository. Works great.
Im using StructureMap for IoC, im getting Configuration from App.Config, like this: public class
I'm using StructureMap in a web project for DI IOC. It works perfect, but
I'm using structureMap as my IoC/DI for an ASP.NET MVC web site. Works great.
I'm currently using StructureMap to inject instances of NHibernate ISessions using the following code:
I have an asp.net mvc2 application that is using StructureMap 2.6 and NHibernate 3.x.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.