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 4614034
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:38:22+00:00 2026-05-22T01:38:22+00:00

I have a sharepoint project where we override search box and some other things.

  • 0

I have a sharepoint project where we override search box and some other things. We also have a web part page that responds to the search box. All these components should share single configuration. I thought about creating a singleton, but I am not sure how would that ever get cleaned up / removed from the memory / uninstalled.

Any ideas? Any warnings about using singletons in sharepoint? Also, is there a proper way to share an instance of an object between all these componenets?

Edit: I was thinking about a very simple singleton. Configuration only needs to contain 5-20 strings and a dozen integers at most. No complex objects 🙂

  • 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-22T01:38:23+00:00Added an answer on May 22, 2026 at 1:38 am

    As long as the objects being managed by your singleton class are thread-safe there shouldn’t be an issue.

    EXAMPLE:
    I have a series of object-calls that were taking a long-time to process (7+ seconds). So, I decided to try using a comet-styled long-polling technique to process them. As such, I host a service (as a static singleton) in a single thread and process requests using asynchronous HttpHandler’s…and it works GREAT! And because I’m using the service asynchronously it’s highly efficient because the calling thread gets released immediately (upon completion of processing the service completes the callback).

    EDIT:
    But your problem of a long processing time still exists, so you still (probably) need an asynchronous solution for the initial fetch. Hows this? Why not COMBINE the asych-solution with custom-caching?

    For various (accessibility) reasons, I save my appSetting’s in the database and use a custom-cache for access thereafter.

    EXAMPLE of a Custom Cache:

    public enum ConfigurationSection
    {
        AppSettings
    }
    
    public static class Utility
    {
        #region "Common.Configuration.Configurations"
    
        private static Cache cache = System.Web.HttpRuntime.Cache;
    
        public static String GetAppSetting(String key)
        {
            return GetConfigurationValue(ConfigurationSection.AppSettings, key);
        }
    
        public static String GetConfigurationValue(ConfigurationSection section, String key)
        {
            Configurations config = null;
    
            if (!cache.TryGetItemFromCache<Configurations>(out config))
            {
                config = new Configurations();
                config.List(SNCLavalin.US.Common.Enumerations.ConfigurationSection.AppSettings);
                cache.AddToCache<Configurations>(config, DateTime.Now.AddMinutes(15));
            }
    
            var result = (from record in config
                          where record.Key == key
                          select record).FirstOrDefault();
    
            return (result == null) ? null : result.Value;
        }
    
        #endregion
    }
    
    namespace Common.Configuration
    {
        public class Configurations : List<Configuration>
        {
            #region CONSTRUCTORS
    
            public Configurations() : base()
            {
                initialize();
            }
            public Configurations(int capacity) : base(capacity)
            {
                initialize();
            }
            public Configurations(IEnumerable<Configuration> collection) : base(collection)
            {
                initialize();
            }
    
            #endregion
    
            #region PROPERTIES & FIELDS
    
            private Crud _crud; // Db-Access layer
    
            #endregion
    
            #region EVENTS
            #endregion
    
            #region METHODS
    
            private void initialize()
            {
                _crud = new Crud(Utility.ConnectionName);
            }
    
            /// <summary>
            /// Lists one-to-many records.
            /// </summary>
            public Configurations List(ConfigurationSection section)
            {
                using (DbCommand dbCommand = _crud.Db.GetStoredProcCommand("spa_LIST_SecConfiguration"))
                {
                    _crud.Db.AddInParameter(dbCommand, "@Section", DbType.String, section.ToString());
    
                    _crud.List(dbCommand, PopulateFrom);
                }
    
                return this;
            }
    
            public void PopulateFrom(DataTable table)
            {
                this.Clear();
    
                foreach (DataRow row in table.Rows)
                {
                    Configuration instance = new Configuration();
                    instance.PopulateFrom(row);
                    this.Add(instance);
                }
            }
    
            #endregion
        }
    
        public class Configuration
        {
            #region CONSTRUCTORS
    
            public Configuration()
            {
                initialize();
            }
    
            #endregion
    
            #region PROPERTIES & FIELDS
    
            private Crud _crud;
    
            public string Section { get; set; }
            public string Key { get; set; }
            public string Value { get; set; }
    
            #endregion
    
            #region EVENTS
            #endregion
    
            #region METHODS
    
            private void initialize()
            {
                _crud = new Crud(Utility.ConnectionName);
                Clear();
            }
    
            public void Clear()
            {
                this.Section = "";
                this.Key = "";
                this.Value = "";
            }
            public void PopulateFrom(DataRow row)
            {
                Clear();
    
                this.Section = row["Section"].ToString();
                this.Key = row["Key"].ToString();
                this.Value = row["Value"].ToString();
            }
    
            #endregion
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a sharepoint project. After I adding the search web part. The
I have a sharepoint page that loads six webparts, each one of them consumes
I have a sharepoint web part where I am programatically adding a button to
I have a sharepoint project that deploys list instances to sharepoint. This has been
I have a SharePoint WebPart project in visual studio. As part of the project
We have got a Sharepoint project at school, we need to include some webparts
I have some Test, Security, Project Management and some other word documents in TFS2010
In sharepoint , i have to create a web application that has an option
I have a Silverlight control packaged up and deployed to a SharePoint web part.
I have a Visual Studio 2010 SharePoint 2010 project that was created with a

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.