コード例 #1
0
        public void ExecuteAssembly(string filename, string[] args, SystemWideLock asmLock)
        {
            AppDomain.CurrentDomain.AssemblyResolve += ResolveEventHandler;
            AppDomain.CurrentDomain.ResourceResolve += ResolveResEventHandler;

            asmFile = filename;
            Assembly assembly;

            if (!ExecuteOptions.options.inMemoryAsm)
            {
                assembly = Assembly.LoadFrom(filename);
            }
            else
            {
                //Load(byte[]) does not lock the assembly file as LoadFrom(filename) does
                byte[] data = File.ReadAllBytes(filename);
                string dbg  = Utils.DbgFileOf(filename);

                if (ExecuteOptions.options.DBG && File.Exists(dbg))
                {
                    byte[] dbgData = File.ReadAllBytes(dbg);
                    assembly = Assembly.Load(data, dbgData);
                }
                else
                {
                    assembly = Assembly.Load(data);
                }

                asmLock?.Release();
            }

            SetScriptReflection(assembly, Path.GetFullPath(filename), true);

            InvokeStaticMain(assembly, args);
        }
コード例 #2
0
        public void ExecuteAssembly(string filename, string[] args, SystemWideLock asmLock)
        {
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandler);
            AppDomain.CurrentDomain.ResourceResolve += new ResolveEventHandler(ResolveResEventHandler); //xaml

            asmFile = filename;

            Assembly assembly;

            if (!ExecuteOptions.options.inMemoryAsm)
            {
                assembly = Assembly.LoadFrom(filename);
            }
            else
            {
                //Load(byte[]) does not lock the assembly file as LoadFrom(filename) does
                byte[] data = File.ReadAllBytes(filename);
                string dbg  = Utils.DbgFileOf(filename);

                if (ExecuteOptions.options.DBG && File.Exists(dbg))
                {
                    byte[] dbgData = File.ReadAllBytes(dbg);
                    assembly = Assembly.Load(data, dbgData);
                }
                else
                {
                    assembly = Assembly.Load(data);
                }

                // using (FileStream fs = new FileStream(filename, FileMode.Open)) // mistake: it opens file for writing (at least on Linux).
                // {
                //     byte[] data = new byte[fs.Length];
                //     fs.Read(data, 0, data.Length);
                //     string dbg = Utils.DbgFileOf(filename);

                //     if (ExecuteOptions.options.DBG && File.Exists(dbg))
                //         using (FileStream fsDbg = new FileStream(dbg, FileMode.Open))
                //         {
                //             byte[] dbgData = new byte[fsDbg.Length];
                //             fsDbg.Read(dbgData, 0, dbgData.Length);
                //             assembly = Assembly.Load(data, dbgData);
                //         }
                //     else
                //         assembly = Assembly.Load(data);
                // }

                asmLock.Release();
            }

#if InterfaceAssembly
            SetScriptReflection(assembly, Path.GetFullPath(filename), CSScript.EnableScriptLocationReflection);
#else
            SetScriptReflection(assembly, Path.GetFullPath(filename), true);
#endif

            InvokeStaticMain(assembly, args);
        }
コード例 #3
0
        public void ExecuteAssembly(string filename, string[] args, SystemWideLock asmLock)
        {
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(ResolveEventHandler);
            AppDomain.CurrentDomain.ResourceResolve += new ResolveEventHandler(ResolveResEventHandler); //xaml

            asmFile = filename;

            Assembly assembly;

            if (!ExecuteOptions.options.inMemoryAsm)
            {
                assembly = Assembly.LoadFrom(filename);
            }
            else
            {
                //Load(byte[]) does not lock the assembly file as LoadFrom(filename) does
                using (FileStream fs = new FileStream(filename, FileMode.Open))
                {
                    byte[] data = new byte[fs.Length];
                    fs.Read(data, 0, data.Length);
                    string dbg = Path.ChangeExtension(filename, ".pdb");

                    if (ExecuteOptions.options.DBG && File.Exists(dbg))
                    {
                        using (FileStream fsDbg = new FileStream(dbg, FileMode.Open))
                        {
                            byte[] dbgData = new byte[fsDbg.Length];
                            fsDbg.Read(dbgData, 0, dbgData.Length);
                            assembly = Assembly.Load(data, dbgData);
                        }
                    }
                    else
                    {
                        assembly = Assembly.Load(data);
                    }
                }

                asmLock.Release();
            }

#if InterfaceAssembly
            SetScriptReflection(assembly, Path.GetFullPath(filename), CSScript.EnableScriptLocationReflection);
#else
            SetScriptReflection(assembly, Path.GetFullPath(filename), true);
#endif


            InvokeStaticMain(assembly, args);
        }