Resolve IAppHost returns null

        var appHost = GetResolver().TryResolve<IAppHost>();
        var path = appHost.VirtualFileSources.RootDirectory.RealPath;

The above code is being run in a Service Post method. appHost is coming back as null. In 3.9.7.1, I was using GetAppHost() which worked just fine. What else do I need to do to get this working with 4.5.10?

The AppHost isn’t in the IOC, you can get it from:

HostContext.AppHost

Or from the Instance singleton in the AppHost:

ServiceStackHost.Instance
AppHostBase.Instance

Which all resolve to the same instance.

1 Like