I've made a powershell Cmdlet for creating an AppFabric a region, the code:
[Cmdlet(VerbsCommon.New, "CacheRegion")]
public class NewCacheRegion : Cmdlet {
[Parameter(Mandatory = true, Position = 1)]
public string Cache { get; set; }
[Parameter(Mandatory = true, Position = 2)]
public string Region { get; set; }
protected override void ProcessRecord() {
base.ProcessRecord();
DataCacheFactory factory = new DataCacheFactory(); // exception
DataCache cache = factory.GetCache(Cache);
try {
cache.CreateRegion(Region);
}
catch (DataCacheException ex) {}
}
}
It's installed with import-module appfabriccmdlet.dll and the code executes when running new-cacheregion.
but the line
DataCacheFactory factory = new DataCacheFactory();
throws an exception that server collection is empty which means that no dataCacheClient section is found in app.config. So I want to a client that but Im not sure in which config file to add the appfabric sections. I've tried finding out from what executable the cmdlet dll is running with
Assembly a = Assembly.GetEntryAssembly();
but that returns null.
So where do I need to put config sections that a cmdlet dll has access to?