tags:

views:

62

answers:

0

Hi,

I am trying to study PRISM , and how to use it , and for that I am following video tutorials.

Anyway, the problem is in my App.config file, which defines the container and the types.

I wrote it as following:

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

  <unity>
    <containers>
      <container>
        <types>

          <type type="CalculatorLibrary.ICalculator , CalculatorLibrary"
                mapTo="Application.Calculator , CalculatorLibrary"/>
          <type type="CalculatorLibrary.ICalculatorReplLopp , InterfacesLibrary"
                mapTo="Application.CalculatorReplLopp , CalculatorLibrary"/>
          <type type="InputOutputLibrary.IInputService , InterfacesLibrary"
                mapTo="Application.ConsolInputService , InputOutputLibrary"/>
          <type type="InputOutputLibrary.IOutputService , InterfacesLibrary"
                mapTo="Application.ConsolOutputService , InputOutputLibrary"/>
          <type type="CalculatorCommandParsingLibrary.IInputParserService , InterfacesLibrary"
                mapTo="Application.InputParserService , CalculatorCommandParsingLibrary"/>

        </types>
      </container>
    </containers>
  </unity>
</configuration>

And here is how I call it and configure the container section

namespace Application
{
    class Program 
    {
        static void Main(string[] args)
        {
            UnityContainer container = new UnityContainer();
            UnityConfigurationSection configSection =
                (UnityConfigurationSection)ConfigurationManager.GetSection("unity");

            configSection.Containers.Default.Configure(container);
            ICalculatorReplLopp loop =    container.Resolve<ICalculatorReplLopp>();
            loop.Run();
        }

        static string[] commands = { "add", "sub", "mul", "div" };
    }
}

I have succeeded to compile it , but I get an exception in runtime as following.

{"Could not load type 'CalculatorLibrary.ICalculator ' from assembly 'CalculatorLibrary'.":"CalculatorLibrary.ICalculator "}

I have uploaded my code to the following link. Hope someone can tell me what is my problem. I am getting crazy of that.

http://www.2shared.com/file/9206133/6535ec6d/Application.html?

Just look at the bottom of the screen and yo will find: "Save file to your PC: click here"

Thank you

related questions