Mono.CSharp.Evaluator.LoadAssembly C# (CSharp) Method

LoadAssembly() public method

Loads the given assembly and exposes the API to the user.
public LoadAssembly ( string file ) : void
file string
return void
        public void LoadAssembly(string file)
        {
            var loader = new DynamicLoader (importer, ctx);
            var assembly = loader.LoadAssemblyFile (file);
            if (assembly == null)
                return;

            lock (evaluator_lock){
                importer.ImportAssembly (assembly, module.GlobalRootNamespace);
            }
        }

Usage Example

        /// <summary>
        ///   Loads the assemblies from a package
        /// </summary>
        /// <remarks>
        ///   Loads the assemblies from a package.   This is equivalent
        ///   to passing the -pkg: command line flag to the C# compiler
        ///   on the command line.
        /// </remarks>
        static public void LoadPackage(string pkg)
        {
            if (pkg == null)
            {
                Error.WriteLine("Invalid package specified");
                return;
            }

            string pkgout = Driver.GetPackageFlags(pkg, false, RootContext.ToplevelTypes.Compiler.Report);

            if (pkgout == null)
            {
                return;
            }

            string [] xargs = pkgout.Trim(new Char [] { ' ', '\n', '\r', '\t' }).
                              Split(new Char [] { ' ', '\t' });

            foreach (string s in xargs)
            {
                if (s.StartsWith("-r:") || s.StartsWith("/r:") || s.StartsWith("/reference:"))
                {
                    string lib = s.Substring(s.IndexOf(':') + 1);

                    Evaluator.LoadAssembly(lib);
                    continue;
                }
            }
        }
All Usage Examples Of Mono.CSharp.Evaluator::LoadAssembly