title: What is this CompositionContainer code in my c# windows service?
body: <p>I am looking at an existing c# windows service project and I have this function that's called in it's constructor ie. before the win service OnStart event. Please can someone please explain what this does? What if I remove this from my service?</p>
  
  <pre><code>    private void Compose()
      {
          CompositionContainer container = null;
  
          try
          {
              string codebase = AppDomain.CurrentDomain.BaseDirectory;
  
              var catalog = new DirectoryCatalog(codebase);
              container = new CompositionContainer(catalog);
              container.ComposeParts(this);
          }
          catch (CompositionException ex)
          {
              foreach (var error in ex.Errors)
              {
                  _logger.Fatal("Error when loading plugin", error.Exception);
              }
          }
          catch (ReflectionTypeLoadException ex)
          {
              foreach (var error in ex.LoaderExceptions)
              {
                  _logger.Fatal("Error when searching for plugin", error);
              }
          }
          catch (Exception ex)
          {
              _logger.Fatal("Error when loading plugin", ex);
          }
          finally
          {
              if (container != null)
              {
                  container.Dispose();
              }
          }
      }
  </code></pre>