Hello,
I’ve a ASP.Net application that exposes servicestack services… before all the services where deployed under different projects and all the projects where referenced by the Web application; in the AppHost I was passing the assemblies in the
private AppHost() //Tell ServiceStack the name and where to find your web services
: base("XXX", typeof (AppHost).Assembly,.....)
and it was working fine.
Now since that application must be installed on different server some assemblies are not to be included on a certain installation… so I removed them and tried to use a ShadowCopy mechanis we use on other Asp.net MVC product that works fine.
Is there a way I can forse servicestack to reload the assemblies that are in the bin folder?
I did some experiment and using
protected override ServiceController CreateServiceController(params Assembly[] assembliesWithServices)
{
return new ServiceController(this, LoadServiceAssemblies);
}
private IEnumerable<Type> LoadServiceAssemblies()
{
var files = Directory.GetFiles(AppDomain.CurrentDomain.RelativeSearchPath, ModuleHelper.ModulePattern);
Log.Debug("Found {files} modules to process", files.Length);
var lst = new List<Type>();
foreach (var f in files)
{
try
{
var assembly = Assembly.LoadFile(f);
var types = assembly.GetTypes();
var assignable = types.Where(t => t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(Service)) && !t.IsInstanceOfType(typeof(ServiceBase))).ToList();
Log.Debug("Procesed {file},Found :{Services} services", f, assignable.Count);
lst.AddRange(assignable);
}
catch (Exception ex)
{
Log.Error(ex, "Error while processing {file}", f);
}
}
return lst;
}
works only If I manually copy to the bin folder… not using the ShadowCopy…
Thanks