Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Configure container in Bootstrapper with Unity

Configure container in Bootstrapper with Unity

Scheduled Pinned Locked Moved C#
questionhelpcsharpcomgame-dev
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kenneth Haugland
    wrote on last edited by
    #1

    I was trying to learn Unity and followed Sashas article Attached VM Behaviours[^] but he defines the Container like so:

    public class Bootstrapper : UnityBootstrapper
    {
      
        ...
    
        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();
    
            //windows
            Container.RegisterType(new ContainerControlledLifetimeManager());
            ...  
        }
    
    }
    

    But when I try and register the shellwindow it tells me that the Container does not exist. I assumed they changed something so my question is if you are not supposed to use the Bootstrapper container at all? I can register types with the code:

        protected override void ConfigureContainer()
        {
            IUnityContainer container = new UnityContainer();
            //windows
            container.RegisterType(new ContainerControlledLifetimeManager());
        
            base.ConfigureContainer();
    
    
        }
    

    But then how do I call Resolve without declaring a property IUnityContainer? [Edit] I get the error message:

    Quote:

    Could not load file or assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f' or one of its dependencies. The system cannot find the file specified.

    All I could find out was this: c# - How to resolve "Could not load file or assembly 'Microsoft.Practices.Prism' " error? - Stack Overflow[^] but it did not solve my problem. [/Edit]

    C K 2 Replies Last reply
    0
    • K Kenneth Haugland

      I was trying to learn Unity and followed Sashas article Attached VM Behaviours[^] but he defines the Container like so:

      public class Bootstrapper : UnityBootstrapper
      {
        
          ...
      
          protected override void ConfigureContainer()
          {
              base.ConfigureContainer();
      
              //windows
              Container.RegisterType(new ContainerControlledLifetimeManager());
              ...  
          }
      
      }
      

      But when I try and register the shellwindow it tells me that the Container does not exist. I assumed they changed something so my question is if you are not supposed to use the Bootstrapper container at all? I can register types with the code:

          protected override void ConfigureContainer()
          {
              IUnityContainer container = new UnityContainer();
              //windows
              container.RegisterType(new ContainerControlledLifetimeManager());
          
              base.ConfigureContainer();
      
      
          }
      

      But then how do I call Resolve without declaring a property IUnityContainer? [Edit] I get the error message:

      Quote:

      Could not load file or assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f' or one of its dependencies. The system cannot find the file specified.

      All I could find out was this: c# - How to resolve "Could not load file or assembly 'Microsoft.Practices.Prism' " error? - Stack Overflow[^] but it did not solve my problem. [/Edit]

      C Offline
      C Offline
      Chris Quinn
      wrote on last edited by
      #2

      Post your question on the article itself - you are much more likely to get an answer there than here

      ========================================================= I'm an optoholic - my glass is always half full of vodka. =========================================================

      K 1 Reply Last reply
      0
      • C Chris Quinn

        Post your question on the article itself - you are much more likely to get an answer there than here

        ========================================================= I'm an optoholic - my glass is always half full of vodka. =========================================================

        K Offline
        K Offline
        Kenneth Haugland
        wrote on last edited by
        #3

        Thing is that it should be a general question. I assumed lots of people had the same issue.

        1 Reply Last reply
        0
        • K Kenneth Haugland

          I was trying to learn Unity and followed Sashas article Attached VM Behaviours[^] but he defines the Container like so:

          public class Bootstrapper : UnityBootstrapper
          {
            
              ...
          
              protected override void ConfigureContainer()
              {
                  base.ConfigureContainer();
          
                  //windows
                  Container.RegisterType(new ContainerControlledLifetimeManager());
                  ...  
              }
          
          }
          

          But when I try and register the shellwindow it tells me that the Container does not exist. I assumed they changed something so my question is if you are not supposed to use the Bootstrapper container at all? I can register types with the code:

              protected override void ConfigureContainer()
              {
                  IUnityContainer container = new UnityContainer();
                  //windows
                  container.RegisterType(new ContainerControlledLifetimeManager());
              
                  base.ConfigureContainer();
          
          
              }
          

          But then how do I call Resolve without declaring a property IUnityContainer? [Edit] I get the error message:

          Quote:

          Could not load file or assembly 'Microsoft.Practices.Unity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=6d32ff45e0ccc69f' or one of its dependencies. The system cannot find the file specified.

          All I could find out was this: c# - How to resolve "Could not load file or assembly 'Microsoft.Practices.Prism' " error? - Stack Overflow[^] but it did not solve my problem. [/Edit]

          K Offline
          K Offline
          Kenneth Haugland
          wrote on last edited by
          #4

          Hrmf.. Started a new project, uploaded all dependencies again, and now everything is working as it should :|

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups