public void Start(FileSystemWatcher watcher, Action removeHostedService)
{
var appDomainSetup = new AppDomainSetup { ConfigurationFile = string.Format("{0}.config", assemblyFile), ShadowCopyFiles = "true", ApplicationBase = Path.GetDirectoryName(assemblyFile)};
appDomain = AppDomain.CreateDomain(string.Format("BottomShelf.Host - {0}", HostedServiceTypeName), new Evidence(), appDomainSetup);
try
{
hostedServiceInstance = (HostedServiceBase)appDomain.CreateInstanceAndUnwrap(assemblyName.FullName, HostedServiceTypeName);
hostedServiceInstance.Start();
}
catch(Exception exception)
{
logger.Error(exception);
removeHostedService();
}
}