本文整理汇总了C#中System.Reflection.Assembly.GetLoadedModules方法的典型用法代码示例。如果您正苦于以下问题:C# Assembly.GetLoadedModules方法的具体用法?C# Assembly.GetLoadedModules怎么用?C# Assembly.GetLoadedModules使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Assembly
的用法示例。
在下文中一共展示了Assembly.GetLoadedModules方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPlugins
/// <summary>
/// Adds plugins in the assembly to the protection list.
/// </summary>
/// <param name="context">The working context.</param>
/// <param name="protections">The working list of protections.</param>
/// <param name="packers">The working list of packers.</param>
/// <param name="components">The working list of components.</param>
/// <param name="asm">The assembly.</param>
protected static void AddPlugins(
ConfuserContext context, IList<Protection> protections, IList<Packer> packers,
IList<ConfuserComponent> components, Assembly asm) {
foreach(var module in asm.GetLoadedModules())
foreach (var i in module.GetTypes()) {
if (i.IsAbstract || !HasAccessibleDefConstructor(i))
continue;
if (typeof(Protection).IsAssignableFrom(i)) {
try {
protections.Add((Protection)Activator.CreateInstance(i));
}
catch (Exception ex) {
context.Logger.ErrorException("Failed to instantiate protection '" + i.Name + "'.", ex);
}
}
else if (typeof(Packer).IsAssignableFrom(i)) {
try {
packers.Add((Packer)Activator.CreateInstance(i));
}
catch (Exception ex) {
context.Logger.ErrorException("Failed to instantiate packer '" + i.Name + "'.", ex);
}
}
else if (typeof(ConfuserComponent).IsAssignableFrom(i)) {
try {
components.Add((ConfuserComponent)Activator.CreateInstance(i));
}
catch (Exception ex) {
context.Logger.ErrorException("Failed to instantiate component '" + i.Name + "'.", ex);
}
}
}
context.CheckCancellation();
}
示例2: ShowAssembly
private void ShowAssembly(Assembly assembly)
{
this.txtResult.AppendText("\r\nAssembly FullName:" + assembly.FullName);
this.txtResult.AppendText("\r\nAssembly Location:" + assembly.Location);
this.txtResult.AppendText("\r\nAssembly CodeBase:" + assembly.CodeBase);
this.txtResult.AppendText("\r\nAssembly EscapedCodeBase:" + assembly.EscapedCodeBase);
//this.txtResult.AppendText("\r\nAssembly EntryPoint:" + assembly.EntryPoint.DeclaringType);
Module[] modules = assembly.GetLoadedModules();
foreach (Module module in modules)
{
ShowModule(module);
}
this.txtResult.AppendText("\r\nAssembly GlobalAssemblyCache:" + assembly.GlobalAssemblyCache);
this.txtResult.AppendText("\r\nAssembly ImageRuntimeVersion:" + assembly.ImageRuntimeVersion);
this.txtResult.AppendText("\r\nAssembly ReflectionOnly:" + assembly.ReflectionOnly);
//this.txtResult.AppendText("\r\nAssembly Location:" + assembly.);
//this.txtResult.AppendText("\r\nAssembly Location:" + assembly.Location);
}
示例3: ShowAssembly
public static void ShowAssembly(Assembly assembly)
{
Console.WriteLine("Assembly FullName:" + assembly.FullName);
Console.WriteLine("Assembly Location:" + assembly.Location);
Console.WriteLine("Assembly CodeBase:"+assembly.CodeBase);
Console.WriteLine("Assembly EscapedCodeBase:" + assembly.EscapedCodeBase);
//Console.WriteLine("Assembly EntryPoint:" + assembly.EntryPoint.DeclaringType);
Module[] modules = assembly.GetLoadedModules();
foreach(Module module in modules)
{
ShowModule(module);
}
Console.WriteLine("Assembly GlobalAssemblyCache:" + assembly.GlobalAssemblyCache);
Console.WriteLine("Assembly ImageRuntimeVersion:" + assembly.ImageRuntimeVersion);
Console.WriteLine("Assembly ReflectionOnly:" + assembly.ReflectionOnly);
//Console.WriteLine("Assembly Location:" + assembly.);
//Console.WriteLine("Assembly Location:" + assembly.Location);
}