Silverlight中枚举并加载客户端程序集

参考如下代码实现:

private static Type GetTypeFromAnyLoadedAssembly(string typeName) {
   Type type = null;
   foreach (AssemblyPart part in Deployment.Current.Parts) {
      StreamResourceInfo resourceStream = Application.GetResourceStream(new Uri(part.Source, UriKind.Relative));
      if (resourceStream != null) {
         Assembly assembly = new AssemblyPart().Load(resourceStream.Stream);
         if (assembly != null) {
            type = Type.GetType(typeName + "," + assembly, false);
         }
      }
      if (type != null) {
         return type;
      }
   }
   return type;
}

你可能感兴趣的:(silverlight)