Steps to reproduce:
1) Create a clean install of Orchard
2) Download and install any theme from the gallery, but DO NOT set to current theme. In this instance I chose the Mango theme, but the issue is reproducible with any theme.
3) Create a class that implements IThemeSelector and selects the theme that you have just installed:
public class ThemeSelector : IThemeSelector
{
private ThemeSelectorResult _requestCache;
private bool _requestCached;
public ThemeSelectorResult GetTheme(System.Web.Routing.RequestContext context)
{
if (_requestCached) { return _requestCache; }
_requestCached = true;
_requestCache = new ThemeSelectorResult { Priority = 10, ThemeName = "Mango" };
return _requestCache;
}
}
4) Browse to your site. Orchard will attempt to use the theme you supplied in the ThemeSelector class, but fails. See attached screenshot.
5) Go to the admin section, and set the theme you installed to the current theme. Now, change the current theme back to the original one.
6) Browse to your site, and the new theme should be rendered correctly, as expected.
Expected behavior:
The theme chosen by your ThemeSelector class should render correctly regardless of whether or not it has been previously set to current theme in the admin back end.