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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:38:26+00:00 2026-05-19T09:38:26+00:00

I have a Unity application that is running and working perfectly but we are

  • 0

I have a Unity application that is running and working perfectly but we are currently in the process of cleaning up our code by acting on all the compilation warnings.

I get a warning on the following piece of code because of the obsolete Microsoft.Practices.Unity.Configuration.ContainerElement.Configure method:

var map = new ExeConfigurationFileMap { ExeConfigFilename = GetConfigFolderForFile("unity.config") };
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
var section = (UnityConfigurationSection)config.GetSection(SectionName);

if (section != null)
{

    var container = new UnityContainer();

    foreach (ContainerElement containerElement in section.Containers)
    {
        containerElement.Configure(container);
    }

    Container = container; // Set the main container
}

I’d like to replace it with the UnityConfigurationSection.Configure method as suggested but can’t see that they are equivalent because of being at different levels of the object hierarchy.

I’ve tried:

var map = new ExeConfigurationFileMap { ExeConfigFilename = GetConfigFolderForFile("unity.config") };
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
var section = (UnityConfigurationSection)config.GetSection(SectionName);

if (section != null)
{
    IUnityContainer container = new UnityContainer();

    container = section.Configure(container);

    Container = container; // Set the main container
}

but that falls down with null references.

How should I be updating the code to eliminate use of the obsolete method?

  • 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-19T09:38:26+00:00Added an answer on May 19, 2026 at 9:38 am

    I have managed to get this to work. The secret was using the overload of the Configure method that takes a container name to configure each container element:

    foreach (ContainerElement containerElement in section.Containers)
    {
        container = section.Configure(container, containerElement.Name);
    }
    

    So far this looks as if it’s doing the same as the obsolete Container.Configure method was doing – everything is working as expected.

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

Sidebar

Related Questions

currently I am working on a spring based application. I do have some unit
We have a Java EE application running in Glassfish 3.1, where we have our
I have read in Patterns of Enterprise Application Architecture that a Unit Of Work
I am having a problem using the Unity Application Block, I have created a
I'm currently looking into unit testing for a new application I have to create.
I have a core data application that uses an NSPredicate in one of its
I have developed an AR application for iPad2 that uses an ImageMarker to display
I am currently trying to write an application that displays live video from a
We have a Web Application Project (dozens actually..) that has a testing project attached
I have the following ant file that is not running the targets prepForDeployment and

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.