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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:23:41+00:00 2026-06-17T14:23:41+00:00

i am first time using any DI framework called unity app block. i am

  • 0

i am first time using any DI framework called unity app block. i am getting error. the error is :-

The type name or alias ILogger could not be resolved. Please check your configuration file and verify this type name.

i was trying inject dependency from out side into my main proj. suppose i want to save data to anywhere by dependency. say suppose i want to save data to file or console, database etc.

here i am telling you how i develop my app for incorporating Unity.

first i create a class library project called “Ilogger” it has only one interface. full code of this interface

namespace Ilogger
{
    public interface ILog
    {
        void Write(string msg);
    }
}

secondly i create a class library project called “ConsoleWriter” it has only one class which inherit Ilogger interface.so i just add the reference of Ilogger project into ConsoleWriter proj. full code of this ConsoleWriter

namespace ConsoleWriter
{
    public class ConsoleWriter : Ilogger.ILog
    {
        #region ILog Members

        public void Write(string msg)
        {
            Console.WriteLine(msg);
            Console.ReadLine();
        }

        #endregion
    }
}

3rd step i create a class library project called “FileWriter
” it has only one class which inherit Ilogger interface.so i just add the reference of Ilogger project into FileWriter proj. full code of this FileWriter

namespace FileWriter
{
    public class FileWriter : Ilogger.ILog
    {
        #region IWriter Members

        public void Write(string msg)
        {
            using (StreamWriter streamWriter = new StreamWriter("c:\\TestUnity.txt", true))
            {
                streamWriter.WriteLine(msg);
            }
        }
        #endregion
    }
}

next i create my win apps from where i inject dependecy at runtime. in this project i add some dll reference of unity block and those are.

Microsoft.Practices.Unity
Microsoft.Practices.Unity.Configuration
system.configuration

i add one app.config file and it has entry like

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/>
    </configSections>

    <unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
        <alias type="ILogger.ILog, ILogger" alias="ILogger" />
        <namespace name="ILogger.ILog"/>

        <container>
            <register mapTo="FileWriter.FileWriter, FileWriter" name="MyFileWriter" type="ILogger"/>
            <register mapTo="ConsoleWriter.ConsoleWriter, ConsoleWriter" name="MyConsoleWriter" type="ILogger"/>
        </container>
    </unity>

</configuration>

here is the main code from where error is thrown

string strCountryCode = “USA”;

    IDictionary<string, string> loggers = new Dictionary<string, string>();
    loggers.Add("USA", "MyFileWriter");
    loggers.Add("GBR", "MyConsoleWriter");

    IUnityContainer container = new UnityContainer();
    UnityConfigurationSection section = (UnityConfigurationSection)System.Configuration.ConfigurationManager.GetSection("unity");
    //container.LoadConfiguration();
    section.Containers.Default.Configure(container);

    Ilogger.ILog logger = container.Resolve<Ilogger.ILog>(loggers[strCountryCode]);
    logger.Write("Hello World");

this line giving error section.Containers.Default.Configure(container);

i am using DI framework unity first time so i am not being able to catch what mistake i made. so please anyone help me to get the error and tell me how to fix it.

thanks

  • 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-06-17T14:23:42+00:00Added an answer on June 17, 2026 at 2:23 pm

    there may be several issues;

    • in the entry point of application, where you are trying to read unity configuration, you need to add the assembly which contains ILog interface; the assembly may be missing.

    • you need to add aliases using full paths; the full path needs to include the assembly name.

    • in order to observe exact problem, instead of using a configuration file, try to make registrations in the code.

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

Sidebar

Related Questions

This is my first time using lightbox which uses jquery framework. But when I
I am using the ADO entity framework for the first time and am not
I'm using bottle for a toy application. It's my first time getting with the
I am using in-app billing from Google for Android for the first time. However,
I'm using Entity Framework 4.1 Code First. In my entity, I have three date/time
My first time using the Entity Framework so I'm not sure if I'm doing
I'm using vs2008 framework 3.5 and i'm looking about linq for first time, following
I am new on Zend framework and using first time it. I am looking
I'm using Flash CS5's new Text Layout Framework (TLF) for the first time. Whenever
First time using Asp.net-mvc and originally followed the NerdDinner tutorial. My form submit button

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.