当前位置: 首页>>代码示例>>C#>>正文


C# Assembly.LoadFile方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:MetalMynds,项目名称:FlatGlass,代码行数:27,代码来源:RelectionHelper.cs

示例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);
 }
开发者ID:pengyancai,项目名称:cs-util,代码行数:12,代码来源:Reflection.cs

示例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);
        }
开发者ID:xen2,项目名称:JSIL,代码行数:52,代码来源:TestUtil.cs


注:本文中的System.Reflection.Assembly.LoadFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。