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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:22:07+00:00 2026-05-15T23:22:07+00:00

How to register an instance in config file I am having this code: UnityContainer.RegisterInstance<ICache>(new

  • 0

How to register an instance in config file

I am having this code:

UnityContainer.RegisterInstance<ICache>(new CacheMng(HttpRuntime.Cache));

And trying to have the equivalent in a config file

<register type="ICache" mapTo="CacheMng">
    <lifetime type="Singleton"/>
    <constructor>
        <param name="cache" type="System.Web.Caching" value="HttpRuntime.Cache"/>
    </constructor>>
</register>

My CacheMng class has this constructor

public CacheMng(Cache cache)
{
    this._cache = cache
}

I’m getting this error

The type name or alias System.Web.Caching could not be resolved

  • 1 1 Answer
  • 2 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-15T23:22:08+00:00Added an answer on May 15, 2026 at 11:22 pm

    The reason you get the error message you see is that the type parameter requires a type name and not a namespace name. System.Web.Caching is a namespace and not a type.

    The only way to do this is to write a custom type converter and use the value element, like this:

    <constructor>
        <param name="cache">
            <value value="" typeConverter="MyHttpRuntimeCacheConverter" />
        </param>
    </constructor>
    

    The type converter looks something like this (in its simplest form):

    public class MyHttpRuntimeCacheConverter : System.ComponentModel.TypeConverter
    {
        public override object ConvertTo(ITypeDescriptorContext context,
                                         CultureInfo culture, object value,
                                         Type destinationType)
        {
            return HttpRuntime.Cache;
        }
    }
    

    You could make this more generally applicable by actually providing a value for the Unity value element (for example: System.Web.HttpRuntime.Cache) and based on this value have the type converter return the right object.

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

Sidebar

Related Questions

I am trying to register a generic type in a config file for Unity
containerBuilder .Register<IGraphClient>(context => { var graphClient = new GraphClient(new Uri(http://localhost:9999/db/data)); graphClient.Connect(); // Particularly this
I am trying to register different converter instances in the faces-config, using a standard
I want to register a specific instance of an object for a type in
Is it possible to install/register another local server instance in any SqlServer version, besides
I'm trying to register a factory method for creating instances of an open generic
using register_shutdown_function I can register code to execute at the end of a PHP
I'm new to Rails and I'm trying to learn it using Rails 3 (RC).
I have the following configuration: builder.Register<EntityContext>().As( c=> { var entityCtx = new EntityContext(); //snip
I have already done the following: Register an instance of my Logger in unity

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.