本文整理汇总了C#中System.AppDomain.GetAssemblies方法的典型用法代码示例。如果您正苦于以下问题:C# AppDomain.GetAssemblies方法的具体用法?C# AppDomain.GetAssemblies怎么用?C# AppDomain.GetAssemblies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.AppDomain
的用法示例。
在下文中一共展示了AppDomain.GetAssemblies方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Reflection;
using System.Security.Policy;
class ADGetAssemblies
{
public static void Main()
{
AppDomain currentDomain = AppDomain.CurrentDomain;
//Provide the current application domain evidence for the assembly.
Evidence asEvidence = currentDomain.Evidence;
//Load the assembly from the application directory using a simple name.
//Create an assembly called CustomLibrary to run this sample.
currentDomain.Load("CustomLibrary",asEvidence);
//Make an array for the list of assemblies.
Assembly[] assems = currentDomain.GetAssemblies();
//List the assemblies in the current application domain.
Console.WriteLine("List of assemblies loaded in current appdomain:");
foreach (Assembly assem in assems)
Console.WriteLine(assem.ToString());
}
}
示例2: Main
//引入命名空间
using System;
using System.Reflection;
using System.Windows.Forms;
public class MainClass
{
public static int Main(string[] args)
{
AppDomain defaultAD = AppDomain.CurrentDomain;
Console.WriteLine("This call loaded System.Windows.Forms.dll and System.dll");
Assembly[] loadedAssemblies = defaultAD.GetAssemblies();
Console.WriteLine("Here are the assemblies loaded in {0}\n",defaultAD.FriendlyName);
foreach(Assembly a in loadedAssemblies)
{
Console.WriteLine("-> Name: {0}", a.GetName().Name);
Console.WriteLine("-> Version: {0}\n", a.GetName().Version);
}
return 0;
}
}