Hi,
We are using IG controls (Win 8.1)..
We have a Utility tool which is using the IG controls.. but as it is to be a standalone appplication (Win form application)we are not suppose put dlls along with the exe or put them in the GAC.. so thought of loading the IG contols dynamically when the Assembly resolve failed...
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
But, the event is not getting fired and application fails with error
Could not load file or assembly 'Infragistics2.Win.v8.1, Version=8.1.20081.2013, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb' or one of its dependencies. The system cannot find the file specified.
Can we load IG asseblies dynamically or not?
Thanks
Ranganatha
Just to give you an idea;
public class AssemblyLoader { private static readonly Dictionary<string, Assembly> cachedAssemblies = new Dictionary<string, Assembly>(); [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] static AssemblyLoader() { AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_OnAssemblyResolve; } /// <summary> /// This method is used to initialize this type through the static constructor for assemblyresolve event handling. /// DO NOT REMOVE THIS METHOD, OR THE CALL TO IT! /// </summary> public static void Initialize() { } public static Assembly CurrentDomain_OnAssemblyResolve(object sender, ResolveEventArgs args) { try { string assemblyName = args.Name; assemblyName = assemblyName.Substring(0, assemblyName.IndexOf(",")); return LoadAssembly(assemblyName); return null; } catch (Exception ex) { Console.WriteLine("converter: " + ex.Message); return null; } } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadFile"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.Reflection.Assembly.LoadFrom")] private static Assembly LoadAssembly(string assemblyName) { Assembly assembly; if (!cachedAssemblies.TryGetValue(assemblyName, out assembly)) { /*Load infragistics assemblies from where you put them in */ } return assembly; } }
I've seen an application load our assemblies dynamically. I've looked for a copy of that project and am unable to find it.
Loading our assemblies in code should be no different than loading any other .NET assembly in code. If your AssemblyResolve event isn't being raised, then it won't work for loading any of your assemblies, whether ours or any other .NET assembly.