Hello,
I have a dialog which loads all classes that belongs to given Interface in the current Assembly , that works very nice without any error on my maschine but does not work on my collegues maschine , it gives him following error
void ClassSelectionDialog_Loaded(object sender, RoutedEventArgs e) { fullpath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); foreach (string dll in Directory.GetFiles(fullpath, "*.dll")) { try { ProxyDomain pd=new ProxyDomain(); Assembly asm = pd.GetAssembly(dll); int cnt = asm.GetTypes().Where(p => p.GetInterface(Interface) != null).Count(); if (cnt > 0) { lstAssemblies.Items.Add(Assembly.LoadFile(dll).GetName().Name); break; } } catch { } } //foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) //{ // lstAssemblies.Items.Add(asm.GetName().Name); //} } class ProxyDomain : MarshalByRefObject { public Assembly GetAssembly(string AssemblyPath) { try { return Assembly.LoadFrom(AssemblyPath); } catch (Exception ex) { throw new InvalidOperationException(ex.Message); } } }
above is my code for loading assembly and classes.
Sincerely, dhampall Please remember to mark the replies as answers if they help and unmark them if they provide no help.