2

I have an object that I currently instantiate in the following way:

var ads = new AppDomainSetup
{
    ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
    DisallowBindingRedirects = false,
    DisallowCodeDownload = false,
    ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
};

domain = AppDomain.CreateDomain("Monitor_" + Id, null, ads);
var sub = (CheckRequestHandler)domain.CreateInstanceAndUnwrap("Alertera.Business",
    "Alertera.Business.Monitoring.CheckRequestHandler");

Is there a way that I can use Autofact to create it? THe object has other dependencies that I'd love for Autofac to handle. Do notice that I'm doing CreateInstanceAndUnwrap. This is important, so that the object is completely unloaded once finished processing. Furthermore, I would like to run that object in a different trust in the future.

Appreciate any advice if Autofac can help here.

Steven
  • 166,672
  • 24
  • 332
  • 435
Igorek
  • 15,716
  • 3
  • 54
  • 92

1 Answers1

1

What you need to do is call into a some factory class that's inside that app domain and that factory class should request that instance from a container instance that is configured inside that appdomain.

Steven
  • 166,672
  • 24
  • 332
  • 435