I tried googling a lot but failed to found a solution.
Please help me through.
I have a windows application setup wizard which will run a installer class where custom actions are assigned to do.
The project lies with a plugin architecture.
While installing, i need to install a printer driver, installer class have code to install it, by calling that plugin.
But, when i try to retrieve the loaded plugin's GetTypes() property, i am receiving a loader-exception Error and Installer will Quit.
If i run my windows application, then GetTypes() property is working properly.
Here is my code. Please have a look and check if anything went wrong.
private static List<Assembly> LoadPlugInAssemblies()
{
DirectoryInfo dInfo = new DirectoryInfo(Path.Combine(Assembly.GetExecutingAssembly().Location.Replace("PluginSDK.dll", ""), "Plugins"));
FileInfo[] files = dInfo.GetFiles("*.dll");
List<Assembly> plugInAssemblyList = new List<Assembly>();
if (null != files)
{
foreach (FileInfo file in files)
{
plugInAssemblyList.Add(Assembly.LoadFile(file.FullName));
}
}
return plugInAssemblyList;
}
static List<IUserFunctionPlugin> GetPlugIns(List<Assembly> assemblies)
{
List<Type> availableTypes = new List<Type>();
foreach (Assembly currentAssembly in assemblies)
availableTypes.AddRange(currentAssembly.GetTypes());
List<Type> pluginList = availableTypes.FindAll(delegate(Type t)
{
List<Type> interfaceTypes = new List<Type>(t.GetInterfaces());
object[] arr = t.GetCustomAttributes(typeof(PluginAttributes), true);
return !(arr == null || arr.Length == 0) && interfaceTypes.Contains(typeof(IUserFunctionPlugin));
});
// CONVERT THE LIST OF OBJECTS TO AN INSTANTIATED LIST OF IPlugins
return pluginList.ConvertAll<IUserFunctionPlugin>(delegate(Type t) { return Activator.CreateInstance(t) as IUserFunctionPlugin; });
}
I tried with Assembly.ReflectionOnlyLoad but resulted with the same error. Thanks in Advance!!!