Certainly Suzanne Cook is the definitive source for details on Assembly.Load and Binding Contexts, a black art tantamount to voodoo that few people understand. Patrick and I have been hip-deep in it lately, and have discovered/uncovered/madecleartoourselves how some of this voodoo works. Here's a (annotated) writeup from Patrick that was sent out internally. Another great resource is Mike Gunderloy's article on Binding Policy in .NET.
All this is mostly an issue for plugins that we load dynamically. It shouldn’t be an issue for compile-time dependencies, since they use full binds. One way to make sure you get what you expect is to specify a full bind in your config files via an Assembly Qualified Name (QN) like: "Foo.Bar, Version=2.0.205.0, Culture=neutral, PublicKeyToken=59388ae2d2746794" and doing something like this:
100 public static object CreateInstance(string assemblyandtype) 101 { 102 Type type = Type.GetType(assemblyandtype); 103 object instance = null; 104 instance = type.InvokeMember(String.Empty,BindingFlags.CreateInstance, null, null, null); 105 return instance; 106 }
Thanks to Patrick for the writeup!
Ads by The Lounge