参考如下代码实现:
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; }
张志敏所有文章遵循创作共用版权协议,要求署名、非商业 、保持一致。在满足创作共用版权协议的基础上可以转载,但请以超链接形式注明出处。
本博客已经迁移到 GitHub , 围观地址: http://beginor.github.io/
本文转自张志敏博客园博客,原文链接:http://www.cnblogs.com/beginor/archive/2009/10/10/1580028.html
,如需转载请自行联系原作者