I have package (Merchello) installed in Umbraco which includes a little ApplicationEventHandler class
public class GatewayResolutionApplicationEventListener : ApplicationEventHandler
{
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
base.ApplicationStarting(umbracoApplication, applicationContext);
PaymentGatewayProviderResolver.Current = new PaymentGatewayProviderResolver(() => PluginManager.Current.ResolveTypes<PaymentGatewayProviderBase>());
TaxationGatewayProviderResolver.Current = new TaxationGatewayProviderResolver(() => PluginManager.Current.ResolveTypes<TaxationGatewayProviderBase>());
ShippingGatewayProviderResolver.Current = new ShippingGatewayProviderResolver(() => PluginManager.Current.ResolveTypes<ShippingGatewayProviderBase>());
}
}
The solvers are really basic sub classes of LazyManyObjectResolverBase
internal sealed class PaymentGatewayProviderResolver : LazyManyObjectsResolverBase<PaymentGatewayProviderResolver, PaymentGatewayProviderBase>
{
/// <summary>
/// Initializes a new instance of the <see cref="PaymentGatewayProviderResolver"/> with an intial list of PaymentGatewayProvider types
/// </summary>
/// <param name="providers">The list of PaymentGatewayProviders</param>
internal PaymentGatewayProviderResolver(Func<IEnumerable<Type>> providers)
: base(providers)
{ }
public IEnumerable<Type> ProviderTypes
{
get { return InstanceTypes; }
}
}
We want to be able to allow other package developers be able to build extensions to Merchello as Umbraco packages and add them to Umbraco via the standard Umbraco install process. If the package (the extension package) contains a binary with has a sub class of PaymentGatewayProviderBase for example, we are trying to get our resolvers identify the class and add it to our list of "Payment Providers". This works beautifully if we simply drop the DLL containing the class to be resolved into the bin file, but our resolvers fail to resolve the class if it is included in a package and added through Umbraco - albeit pulling the dll out of the bin directory and immediately dropping it back in does force the resolution.
Also, in my previous description, I eluded to restarting the application pool corrects the issue. This actually turns out not to be true. Restarting IIS does not do it either - we have to remove the DLL from the bin and drop it back in or delete the PluginCache and restart the application pool.
Is there a way to refresh the PluginCache?