title: How to resolve all forms using unity container
body: <p>I use unity container in my WinForms application and register interfaces and classes. but when open other forms it's not working for fetching data. It's just working for form1.
  How to resolve all forms?</p>
  
  <pre><code>static class Program
  {
      [STAThread]
      static void Main()
      {
          Application.EnableVisualStyles();
          Application.SetCompatibleTextRenderingDefault(false);
          RegisterType(new UnityContainer());
      }
  
      public static void RegisterType(IUnityContainer container)
      {
          container.RegisterType&lt;IBlogRepository, BlogRepository&gt;();
          container.RegisterType&lt;IPostRepository, PostRepository&gt;();
  
          Application.Run(container.Resolve&lt;Form1&gt;());
      }
  }
  </code></pre>
  
  <p>This is constructor injection in form1():</p>
  
  <pre><code>public partial class Form1: Form
  {
      public Form1()
      {
          InitializeComponent();
      }
  
      private readonly IBlogRepository _blogRepository;
  
      public Form1(IBlogRepository blogRepository) : this()
      {
          _blogRepository = blogRepository;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>and this is constructor injection in formAddUpdate():</p>
  
  <pre><code>public partial class FormAddUpdate : Form
  {
      public FormAddUpdate()
      {
          InitializeComponent();
      }
  
      private readonly IBlogRepository _blogRepository;
      private readonly IPostRepository _postRepository;
  
      public FormAddUpdate(IBlogRepository blogRepository, IPostRepository postRepository) : this()
      {
          _blogRepository = blogRepository;
          _postRepository = postRepository;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>now when the run application I can retrieve data from from1 but when switch to add/update form, it returns error:       {"Object reference not set to an instance of an object."}</p>
  
  <p>How to resolve all forms in my application?</p>