我正在看一個現有的C#windows服務項目,我有這個函數在它的構造函數即ie中調用。贏得服務OnStart事件之前。請有人可以解釋這是什麼?如果我從我的服務中刪除這個,怎麼辦?我的c#windows服務中的這個CompositionContainer代碼是什麼?
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();
}
}
}
也許MSDN可以幫助你呢? http://msdn.microsoft.com/en-us/library/system.componentmodel.composition.hosting.compositioncontainer(v=vs.110).aspx – Overmachine