本文整理汇总了C#中System.Reflection.Assembly.LoadFile方法的典型用法代码示例。如果您正苦于以下问题:C# Assembly.LoadFile方法的具体用法?C# Assembly.LoadFile怎么用?C# Assembly.LoadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Assembly
的用法示例。
在下文中一共展示了Assembly.LoadFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryLoadAssembly
public static Boolean TryLoadAssembly(AppDomain Domain, String Path, out Assembly Assembly, out String Error)
{
Assembly assembly;
try
{
if (TryGetLoadedAssembly(Domain, Path, out assembly))
{
Error = String.Empty;
Assembly = assembly;
return true;
}
else
{
assembly = Assembly.LoadFile(Path);
Error = String.Empty;
Assembly = assembly;
return true;
}
}
catch (Exception ex)
{
Assembly = null;
Error = String.Format("Try Load Assembly Failed!\nError: {0}\nFilename: {1}", ex.Message, Path);
return false;
}
}
示例2: GetTypes
/// <summary>
/// Gets a list of types based on an interface
/// </summary>
/// <param name="AssemblyLocation">Location of the DLL</param>
/// <param name="Interface">Interface to look for</param>
/// <param name="Assembly">The assembly holding the types</param>
/// <returns>A list of types that use the interface</returns>
public static System.Collections.Generic.List<Type> GetTypes(string AssemblyLocation, string Interface,out Assembly Assembly)
{
Assembly = Assembly.LoadFile(AssemblyLocation);
return GetTypes(Assembly, Interface);
}
示例3: ComparisonTest
public ComparisonTest(
EvaluatorPool pool,
IEnumerable<string> filenames, string outputPath,
string[] stubbedAssemblies = null, TypeInfoProvider typeInfo = null,
AssemblyCache assemblyCache = null
)
{
var started = DateTime.UtcNow.Ticks;
OutputPath = outputPath;
EvaluatorPool = pool;
var extensions = (from f in filenames select Path.GetExtension(f).ToLower()).Distinct().ToArray();
var absoluteFilenames = (from f in filenames select Path.Combine(TestSourceFolder, f));
if (extensions.Length != 1)
throw new InvalidOperationException("Mixture of different source languages provided.");
var assemblyNamePrefix = Path.GetDirectoryName(outputPath).Split(new char[] { '\\', '/' }).Last();
var assemblyName = Path.Combine(
assemblyNamePrefix,
Path.GetFileName(outputPath).Replace(".js", "")
);
switch (extensions[0]) {
case ".cs":
Assembly = CompilerUtil.CompileCS(absoluteFilenames, assemblyName);
break;
case ".vb":
Assembly = CompilerUtil.CompileVB(absoluteFilenames, assemblyName);
break;
case ".exe":
case ".dll":
var fns = absoluteFilenames.ToArray();
if (fns.Length > 1)
throw new InvalidOperationException("Multiple binary assemblies provided.");
Assembly = Assembly.LoadFile(fns[0]);
break;
default:
throw new ArgumentException("Unsupported source file type for test");
}
if (typeInfo != null)
typeInfo.ClearCaches();
StubbedAssemblies = stubbedAssemblies;
TypeInfo = typeInfo;
AssemblyCache = assemblyCache;
var ended = DateTime.UtcNow.Ticks;
CompilationElapsed = TimeSpan.FromTicks(ended - started);
}