コード例 #1
0
 System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
 {
     var ass = AppDomain.CurrentDomain.GetAssemblies();
     var trgName = new System.Reflection.AssemblyName(args.Name);
     foreach (var a in ass)
     {
         var aN = new System.Reflection.AssemblyName(a.FullName);
         if (aN.Name == trgName.Name)
         {
             return a;
         }
     }
     if (trgName.Name == "gnomorialib")
     {
         return System.Reflection.Assembly.Load(System.IO.File.ReadAllBytes(System.IO.Path.Combine(base_dir, trgName.Name + "Modded.dll")));
     }
     var file = System.IO.Path.Combine(base_dir, trgName.Name + ".dll");
     if (trgName.Name == "GnomoriaModController")
     {
         return System.Reflection.Assembly.Load(System.IO.File.ReadAllBytes(file));
     }
     else if (System.IO.File.Exists(file))
     {
         return System.Reflection.Assembly.LoadFile(file);
     }
     return null;
 }
コード例 #2
0
		private BXWizardResult InstallConfig()
		{
			Directory.CreateDirectory(BXPath.MapPath("~/bitrix/updates"));
			if (!File.Exists(BXPath.MapPath("~/bitrix/updates/updater.config")))
			{
				BXUpdaterConfig config = SiteUpdater.BXSiteUpdater.GetConfig();

				config.UpdateUrl = GetMessage("Updater.Server") ?? "http://www.bitrixsoft.com";
				config.Language = WizardContext.Locale;
				config.Key = "";
				System.Reflection.AssemblyName name = new System.Reflection.AssemblyName(typeof(BXUpdaterConfig).Assembly.FullName);
				config.Version = new BXUpdaterVersion(name.Version.Major, name.Version.Minor, name.Version.Build);
				
				string proxy = WizardContext.State.GetString("Options.UpdaterProxy");
				if (!string.IsNullOrEmpty(proxy))
				{
					config.UseProxy = true;
					config.ProxyAddress = proxy;
					
					string user = WizardContext.State.GetString("Options.UpdaterProxyUsername");
					if (!string.IsNullOrEmpty(user))
					{
						config.ProxyUsername = user;
						string password = WizardContext.State.GetString("Options.UpdaterProxyPassword");
						if (!string.IsNullOrEmpty(password))
							config.ProxyPassword = password;						
					}				
				}

				config.Update();
			}

			return Result.Action("finalize");
		}		
コード例 #3
0
ファイル: MSBuildCompiler.cs プロジェクト: dbremner/specsharp
        public Assembly CompileProject(string projectFileName)
        {
            Assembly existing;
            if (Compilations.TryGetValue(Path.GetFullPath(projectFileName), out existing))
            {
                return existing;
            }

            var project = new Microsoft.Build.BuildEngine.Project();
            project.Load(projectFileName);

            var projectName = Environment.NameTable.GetNameFor(project.EvaluatedProperties["AssemblyName"].Value);
            var projectPath = project.FullFileName;
            var compilerOptions = new SpecSharpOptions();
            var assemblyReferences = new List<IAssemblyReference>();
            var moduleReferences = new List<IModuleReference>();
            var programSources = new List<SpecSharpSourceDocument>();
            var assembly = new SpecSharpAssembly(projectName, projectPath, Environment, compilerOptions, assemblyReferences, moduleReferences, programSources);
            var helper = new SpecSharpCompilationHelper(assembly.Compilation);

            Compilations[Path.GetFullPath(projectFileName)] = assembly;

            assemblyReferences.Add(Environment.LoadAssembly(Environment.CoreAssemblySymbolicIdentity));
            project.Build("ResolveAssemblyReferences");
            foreach (BuildItem item in project.GetEvaluatedItemsByName("ReferencePath"))
            {
                var assemblyName = new System.Reflection.AssemblyName(item.GetEvaluatedMetadata("FusionName"));
                var name = Environment.NameTable.GetNameFor(assemblyName.Name);
                var culture = assemblyName.CultureInfo != null ? assemblyName.CultureInfo.Name : "";
                var version = assemblyName.Version == null ? new Version(0, 0) : assemblyName.Version;
                var token = assemblyName.GetPublicKeyToken();
                if (token == null) token = new byte[0];
                var location = item.FinalItemSpec;
                var identity = new AssemblyIdentity(name, culture, version, token, location);
                var reference = Environment.LoadAssembly(identity);
                assemblyReferences.Add(reference);
            }

            foreach (BuildItem item in project.GetEvaluatedItemsByName("ProjectReference"))
            {
                var name = Environment.NameTable.GetNameFor(Path.GetFileNameWithoutExtension(item.FinalItemSpec));
                var location = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(project.FullFileName), item.FinalItemSpec));
                var reference = CompileProject(location);
                assemblyReferences.Add(reference);
            }

            foreach (BuildItem item in project.GetEvaluatedItemsByName("Compile"))
            {
                var location = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(project.FullFileName), item.FinalItemSpec));
                var name = Environment.NameTable.GetNameFor(location);
                var programSource = new SpecSharpSourceDocument(helper, name, location, File.ReadAllText(location));
                programSources.Add(programSource);
            }

            return assembly;
        }
コード例 #4
0
ファイル: AssemblyLoader.cs プロジェクト: danaxa/Pencil
 IAssembly IAssemblyLoader.Load(AssemblyName assembly)
 {
     try {
         return new Assembly(new DefaultTypeLoader(), Load(assembly));
     } catch(FileLoadException) {
         return new MissingAssembly(assembly);
     } catch(FileNotFoundException) {
         return new MissingAssembly(assembly);
     }
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: alex-polosky/EntityEngine
        static void Main()
        {
            AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
            {
                var filename = new System.Reflection.AssemblyName(e.Name).Name;
                var path = System.IO.Directory.GetCurrentDirectory().Split(System.IO.Path.DirectorySeparatorChar).ToList();
                while (path[path.Count() - 1] != "Bin")
                    path.RemoveAt(path.Count() - 1);
                var pathBin = string.Join(System.IO.Path.DirectorySeparatorChar.ToString(), path);
                path[path.Count() - 1] = "Lib";
                var pathLib = string.Join(System.IO.Path.DirectorySeparatorChar.ToString(), path);
                // Attempt to load from lib first
                foreach (var file in System.IO.Directory.GetFiles(pathLib))
                {
                    if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[]{".dll"}, StringSplitOptions.None)[0] == filename)
                        return System.Reflection.Assembly.LoadFrom(file);
                }
                foreach (var dir in System.IO.Directory.GetDirectories(pathLib))
                {
                    foreach (var file in System.IO.Directory.GetFiles(dir))
                    {
                        if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[] { ".dll" }, StringSplitOptions.None)[0] == filename)
                            return System.Reflection.Assembly.LoadFrom(file);
                    }
                }
                // Attempt to load from bin
                foreach (var file in System.IO.Directory.GetFiles(pathBin))
                {
                    if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[] { ".dll" }, StringSplitOptions.None)[0] == filename)
                        return System.Reflection.Assembly.LoadFrom(file);
                }
                foreach (var dir in System.IO.Directory.GetDirectories(pathBin))
                {
                    foreach (var file in System.IO.Directory.GetFiles(dir))
                    {
                        if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[] { ".dll" }, StringSplitOptions.None)[0] == filename)
                            return System.Reflection.Assembly.LoadFrom(file);
                    }
                }
                return null;
            };
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new gameEditorMainForm());
            //Application.Run(new TestJsonEdit());
            //Application.Run(new Dialog.Forms.GuidSelector());
            //Application.Run(new Dialog.Forms.GuidManagerForm());
            Application.Run(new mainForm());

            //new TestJsonEdit().Show();
            //new mainForm().Show();
            //new Dialog.Forms.GuidSelector().Show();
            //new Dialog.Forms.GuidManagerForm().Show();
            //Application.Run(new Form());
        }
コード例 #6
0
ファイル: AssemblyLoader.cs プロジェクト: danaxa/Pencil
 ReflectionAssembly Load(AssemblyName assembly)
 {
     try {
         return ReflectionAssembly.Load(assembly);
     } catch (FileLoadException) {
         var altPath = Path.Combine(binPath, assembly.Name + ".dll");
         if (File.Exists(altPath))
             return ReflectionAssembly.LoadFrom(altPath);
         throw;
     }
 }
コード例 #7
0
ファイル: App.xaml.cs プロジェクト: susemeee/YangpaH
        public App()
        {
            //integrated SQLite dll : unmanaged code
            AppDomain.CurrentDomain.AssemblyResolve += (sender1, args) =>
            {
                string resourceName = new System.Reflection.AssemblyName(args.Name).Name + ".dll";
                string resource = Array.Find(this.GetType().Assembly.GetManifestResourceNames(), element => element.EndsWith(resourceName));
                EmbeddedAssembly.Load(resource, resourceName);

                return EmbeddedAssembly.Get(args.Name);
            };
        }
コード例 #8
0
ファイル: MotoresComercial.cs プロジェクト: AccSy/CSU_MIT
 /// <summary>
 /// Método para resolução das assemblies.
 /// </summary>
 /// <param name="sender">Application</param>
 /// <param name="args">Resolving Assembly Name</param>
 /// <returns>Assembly</returns>
 static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
 {
     string assemblyFullName;
     System.Reflection.AssemblyName assemblyName;
     string PRIMAVERA_COMMON_FILES_FOLDER = Instancia.daPastaConfig();//pasta dos ficheiros comuns especifica da versão do ERP PRIMAVERA utilizada.
     assemblyName = new System.Reflection.AssemblyName(args.Name);
     assemblyFullName = System.IO.Path.Combine(System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFilesX86), PRIMAVERA_COMMON_FILES_FOLDER), assemblyName.Name + ".dll");
     if (System.IO.File.Exists(assemblyFullName))
         return System.Reflection.Assembly.LoadFile(assemblyFullName);
     else
         return null;
 }
コード例 #9
0
        public static AssemblyIdentity Parse(INameTable nameTable, string formattedName)
        {
            var name = new System.Reflection.AssemblyName(formattedName);
            return new AssemblyIdentity(nameTable.GetNameFor(name.Name),
                                        name.CultureName,
                                        name.Version,
                                        name.GetPublicKeyToken(),
#if COREFX
                                        "");
#else
                                        name.CodeBase);
#endif
        }
コード例 #10
0
 static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
 {
     System.Reflection.AssemblyName name = new System.Reflection.AssemblyName(args.Name);
     if (name.Name.ToLowerInvariant().EndsWith(".resources")) return null;
     string installPath = HpToolsLauncher.Helper.getLRInstallPath();
     if (installPath == null)
     {
         log(Resources.CannotLocateInstallDir);
         Environment.Exit((int)Launcher.ExitCodeEnum.Aborted);
     }
     //log(Path.Combine(installPath, "bin", name.Name + ".dll"));
     return System.Reflection.Assembly.LoadFrom(Path.Combine(installPath, "bin", name.Name + ".dll"));
 }
コード例 #11
0
ファイル: Global.cs プロジェクト: nickchal/pash
		public Global()
		{
			var root = ConfigurationManager.AppSettings["RootPath"];
			AppDomain.CurrentDomain.AssemblyResolve += (object sender, ResolveEventArgs args) => {
				var assemblyName = new System.Reflection.AssemblyName(args.Name);
				string path = System.IO.Path.Combine (root, assemblyName.Name + ".dll");
				if (System.IO.File.Exists (path))
				{
					return System.Reflection.Assembly.LoadFile (path);
				}
				return null;
			};
		}
コード例 #12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="assmName"></param>
        public static void CreateRegExDLL(string assmName)
        {
            RegexCompilationInfo[] RE = new RegexCompilationInfo[2]
            {new RegexCompilationInfo("PATTERN", RegexOptions.Compiled,
                                  "CompiledPATTERN", "Chapter_Code", true),
             new RegexCompilationInfo("NAME", RegexOptions.Compiled,
                                  "CompiledNAME", "Chapter_Code", true)};

            System.Reflection.AssemblyName aName =
                 new System.Reflection.AssemblyName();
            aName.Name = assmName;

            Regex.CompileToAssembly(RE, aName);
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: CodeFork/PluginFramework-1
        static void Main(string[] args)
        {
            System.Reflection.AssemblyName myAssemblyName = new System.Reflection.AssemblyName("Fubar, Version=100.0.0.2001, Culture=sv-FI, PublicKeyToken=null");
              Console.WriteLine("Name: {0}", myAssemblyName.Name);
              Console.WriteLine("Version: {0}", myAssemblyName.Version);
              Console.WriteLine("CultureInfo: {0}", myAssemblyName.CultureInfo);
              Console.WriteLine("FullName: {0}", myAssemblyName.FullName);

              Console.WriteLine("Assembly: {0}", typeof(Tuple<string, int>).Assembly.FullName);
              Console.WriteLine("Type: {0}", typeof(Tuple<string, int>).FullName);

              using (var program = new Program())
            program.Run();
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: midiway/FontLister
        static Program()
        {
            // see https://github.com/google/google-api-dotnet-client/issues/554#issuecomment-115729788
            var httpasm = typeof(System.Net.Http.HttpClient).Assembly;
            var httpver = new Version(1, 5, 0, 0);

            AppDomain.CurrentDomain.AssemblyResolve += (s, a) => {
                var requestedAssembly = new System.Reflection.AssemblyName(a.Name);
                if (requestedAssembly.Name != "System.Net.Http" || requestedAssembly.Version != httpver)
                    return null;

                return httpasm;
            };
        }
コード例 #15
0
 public static WriteableBitmap FromResource(this WriteableBitmap bmp, string relativePath)
 {
     if (bmp == null) 
         throw new ArgumentNullException("bmp");
     var fullName = System.Reflection.Assembly.GetCallingAssembly().FullName;
     var asmName = new System.Reflection.AssemblyName(fullName).Name;
     using (var bmpStream = Application.GetResourceStream(new Uri(string.Format("{0};component/{1}", asmName, relativePath), UriKind.Relative)).Stream)
     {
         var bmpi = new BitmapImage();
         bmpi.SetSource(bmpStream);
         bmp = new WriteableBitmap(bmpi);
         return bmp;
     }
 }
コード例 #16
0
        public static string Format(this AssemblyIdentity assemblyIdentity)
        {
            var name = new System.Reflection.AssemblyName();
            name.Name = assemblyIdentity.Name.Value;
#if !COREFX
            name.CultureInfo = new CultureInfo(assemblyIdentity.Culture);
#endif
            name.Version = assemblyIdentity.Version;
            name.SetPublicKeyToken(assemblyIdentity.PublicKeyToken.ToArray());
#if !COREFX
            name.CodeBase = assemblyIdentity.Location;
#endif
            return name.ToString();
        }
コード例 #17
0
        public void Initialize()
        {
            var assembly = System.Reflection.Assembly.GetExecutingAssembly();
            var name = new System.Reflection.AssemblyName(assembly.FullName);

            AddInfo("CodeBase", name.CodeBase);
            AddInfo("ContentType", name.ContentType.ToString());
            AddInfo("CultureInfo", name.CultureInfo != null ? name.CultureInfo.ToString() : "");
            AddInfo("CultureName", name.CultureName);
            AddInfo("Flags", name.Flags.ToString());
            AddInfo("FullName", name.FullName);
            AddInfo("HashAlgorithm", name.HashAlgorithm.ToString());
            AddInfo("Name", name.Name);
            AddInfo("Version", name.Version != null ? name.Version.ToString() : "");
            AddInfo("VersionCompatibility", name.VersionCompatibility.ToString());
        }
コード例 #18
0
		public static void Init(){
			// This code automatically loads required dlls from embedded resources.
			AppDomain.CurrentDomain.AssemblyResolve += delegate(System.Object sender, ResolveEventArgs delArgs)
			{
				string assemblyName = new System.Reflection.AssemblyName(delArgs.Name).Name;
				String resourceName = assemblyName + ".dll";
				using (System.IO.Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
				{
					if (stream == null)
						return null;
					Byte[] assemblyData = new Byte[stream.Length];
					stream.Read(assemblyData, 0, assemblyData.Length);
					return System.Reflection.Assembly.Load(assemblyData);
				}
			};
		}
コード例 #19
0
 private static System.Reflection.Assembly Load(string assemblyNameVal) {
     System.Reflection.AssemblyName assemblyName = new System.Reflection.AssemblyName(assemblyNameVal);
     byte[] publicKeyToken = assemblyName.GetPublicKeyToken();
     System.Reflection.Assembly asm = null;
     try {
         asm = System.Reflection.Assembly.Load(assemblyName.FullName);
     }
     catch (System.Exception ) {
         System.Reflection.AssemblyName shortName = new System.Reflection.AssemblyName(assemblyName.Name);
         if ((publicKeyToken != null)) {
             shortName.SetPublicKeyToken(publicKeyToken);
         }
         asm = System.Reflection.Assembly.Load(shortName);
     }
     return asm;
 }
コード例 #20
0
ファイル: Program.cs プロジェクト: alex-polosky/EntityEngine
 static void BootStrap0()
 {
     AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
     {
         var filename = new System.Reflection.AssemblyName(e.Name).Name;
         var path = System.IO.Directory.GetCurrentDirectory().Split(System.IO.Path.DirectorySeparatorChar).ToList();
         while (path[path.Count() - 1] != "Bin")
             path.RemoveAt(path.Count() - 1);
         var pathBin = string.Join(System.IO.Path.DirectorySeparatorChar.ToString(), path);
         path[path.Count() - 1] = "Lib";
         var pathLib = string.Join(System.IO.Path.DirectorySeparatorChar.ToString(), path);
         // Attempt to load from lib first
         foreach (var file in System.IO.Directory.GetFiles(pathLib))
         {
             if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[]{".dll"}, StringSplitOptions.None)[0] == filename)
                 return System.Reflection.Assembly.LoadFrom(file);
         }
         foreach (var dir in System.IO.Directory.GetDirectories(pathLib))
         {
             foreach (var file in System.IO.Directory.GetFiles(dir))
             {
                 if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[] { ".dll" }, StringSplitOptions.None)[0] == filename)
                     return System.Reflection.Assembly.LoadFrom(file);
             }
         }
         // Attempt to load from bin
         foreach (var file in System.IO.Directory.GetFiles(pathBin))
         {
             if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[] { ".dll" }, StringSplitOptions.None)[0] == filename)
                 return System.Reflection.Assembly.LoadFrom(file);
         }
         foreach (var dir in System.IO.Directory.GetDirectories(pathBin))
         {
             foreach (var file in System.IO.Directory.GetFiles(dir))
             {
                 if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[] { ".dll" }, StringSplitOptions.None)[0] == filename)
                     return System.Reflection.Assembly.LoadFrom(file);
             }
         }
         return null;
     };
     var asm = System.Reflection.Assembly.GetExecutingAssembly();
     Type t = asm.GetType(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".Program");
     t.GetMethod("BootStrap", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static).Invoke(null, null);
 }
コード例 #21
0
 public void Setup()
 {
     AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
     {
         var filename = new System.Reflection.AssemblyName(e.Name).Name;
         var path = System.IO.Directory.GetCurrentDirectory().Split(System.IO.Path.DirectorySeparatorChar).ToList();
         while (path[path.Count() - 1] != "Bin")
             path.RemoveAt(path.Count() - 1);
         var pathBin = string.Join(System.IO.Path.DirectorySeparatorChar.ToString(), path);
         path[path.Count() - 1] = "Lib";
         var pathLib = string.Join(System.IO.Path.DirectorySeparatorChar.ToString(), path);
         // Attempt to load from lib first
         foreach (var file in System.IO.Directory.GetFiles(pathLib))
         {
             if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[] { ".dll" }, StringSplitOptions.None)[0] == filename)
                 return System.Reflection.Assembly.LoadFrom(file);
         }
         foreach (var dir in System.IO.Directory.GetDirectories(pathLib))
         {
             foreach (var file in System.IO.Directory.GetFiles(dir))
             {
                 if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[] { ".dll" }, StringSplitOptions.None)[0] == filename)
                     return System.Reflection.Assembly.LoadFrom(file);
             }
         }
         // Attempt to load from bin
         foreach (var file in System.IO.Directory.GetFiles(pathBin))
         {
             if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[] { ".dll" }, StringSplitOptions.None)[0] == filename)
                 return System.Reflection.Assembly.LoadFrom(file);
         }
         foreach (var dir in System.IO.Directory.GetDirectories(pathBin))
         {
             foreach (var file in System.IO.Directory.GetFiles(dir))
             {
                 if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[] { ".dll" }, StringSplitOptions.None)[0] == filename)
                     return System.Reflection.Assembly.LoadFrom(file);
             }
         }
         return null;
     };
     Console.WriteLine("AppDomain has been set if required");
 }
コード例 #22
0
ファイル: Program.cs プロジェクト: PabloCorso/BattleNotifier
        static void Main(string[] args)
        {
            using (Mutex mutex = new Mutex(false, appGuid))
            {
                bool waitOne = mutex.WaitOne(0, false);
                if (!waitOne)
                {
                    MessageBox.Show("An instance of Battle Notifier is already running.", "Calm your horses", MessageBoxButtons.OK);
                    return;
                }

                LaunchedViaStartup = args != null && args.Any(arg => arg.Equals("/startminimized", StringComparison.CurrentCultureIgnoreCase));

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                AppDomain.CurrentDomain.AssemblyResolve += (Object sender, ResolveEventArgs reargs) =>
                {
                    string thisExe = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
                    System.Reflection.AssemblyName embeddedAssembly = new System.Reflection.AssemblyName(reargs.Name);
                    string resourceName = thisExe + "." + embeddedAssembly.Name + ".dll";

                    using (var stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
                    {
                        Byte[] assemblyData = new Byte[stream.Length];
                        stream.Read(assemblyData, 0, assemblyData.Length);
                        return System.Reflection.Assembly.Load(assemblyData);
                    }
                };

                Main main = new Main();
                Application.Run(main);
                main.DisposeBattleNotification();
                if (mutex != null && waitOne)
                    mutex.ReleaseMutex();
            }
        }
コード例 #23
0
			public CecilProjectContent(string fullName, string fileName, AssemblyName[] referencedAssemblies,
			                           TypeDefinitionCollection types, ProjectContentRegistry registry)
				: base(fullName, fileName, referencedAssemblies, registry)
			{
				foreach (TypeDefinition td in types) {
					if ((td.Attributes & TypeAttributes.Public) == TypeAttributes.Public) {
						if ((td.Attributes & TypeAttributes.NestedAssembly) == TypeAttributes.NestedAssembly
						    || (td.Attributes & TypeAttributes.NestedPrivate) == TypeAttributes.NestedPrivate
						    || (td.Attributes & TypeAttributes.NestedFamANDAssem) == TypeAttributes.NestedFamANDAssem)
						{
							continue;
						}
						string name = td.FullName;
						if (name.Length == 0 || name[0] == '<')
							continue;
						if (name.Length > 2 && name[name.Length - 2] == '`')
							name = name.Substring(0, name.Length - 2);
						AddClassToNamespaceListInternal(new CecilClass(this.AssemblyCompilationUnit, null, td, name));
					}
				}
				InitializeSpecialClasses();
			}
コード例 #24
0
 private System.Reflection.Emit.ModuleBuilder GetModuleBuilder()
 {
     System.Reflection.AssemblyName an = new System.Reflection.AssemblyName();
     an.Name = "TempAssembly";
     System.AppDomain ad = System.AppDomain.CurrentDomain;
     System.Reflection.Assembly[] assemblys = ad.GetAssemblies();
     System.Reflection.Emit.ModuleBuilder mb;
     foreach (System.Reflection.Assembly a in assemblys)
     {
         if (a.GetType() == Type.GetType("System.Reflection.Emit.AssemblyBuilder") && a.GetName().Name == "TempAssembly")
         {
             a.GetModules();
             mb = (System.Reflection.Emit.ModuleBuilder)a.GetModule("TempModule");
             return mb;
         }
     }
     return ad.DefineDynamicAssembly(an, System.Reflection.Emit.AssemblyBuilderAccess.Run).DefineDynamicModule("TempModule");
 }
コード例 #25
0
ファイル: ClrModule.cs プロジェクト: ruisebastiao/pythonnet
// ReSharper disable InconsistentNaming
    public static void initclr()
// ReSharper restore InconsistentNaming    
    {
#if DEBUG_PRINT
        System.Console.WriteLine("Attempting to load Python.Runtime using standard binding rules... ");
#endif
#if USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN
        var pythonRuntimePublicKeyTokenData = new byte[] { 0x50, 0x00, 0xfe, 0xa6, 0xcb, 0xa7, 0x02, 0xdd };
#endif

        // Attempt to find and load Python.Runtime using standard assembly binding rules.
        // This roughly translates into looking in order:
        // - GAC
        // - ApplicationBase
        // - A PrivateBinPath under ApplicationBase
        // With an unsigned assembly, the GAC is skipped.
        var pythonRuntimeName = new System.Reflection.AssemblyName("Python.Runtime")
            {
#if USE_PYTHON_RUNTIME_VERSION
                Version = new System.Version("4.0.0.1"), 
#endif
                CultureInfo = System.Globalization.CultureInfo.InvariantCulture,
            };
#if USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN
        pythonRuntimeName.SetPublicKeyToken(pythonRuntimePublicKeyTokenData);
#endif
        // We've got the AssemblyName with optional features; try to load it.
        System.Reflection.Assembly pythonRuntime;
        try
        {
            pythonRuntime = System.Reflection.Assembly.Load(pythonRuntimeName);
#if DEBUG_PRINT
            System.Console.WriteLine("Success!");
#endif
        }
        catch (System.IO.FileNotFoundException)
        {
            try
            {
                // If the above fails for any reason, we fallback to attempting to load "Python.Runtime.dll"
			    // from the directory this assembly is running in. "This assembly" is probably "clr.pyd",
			    // sitting somewhere in PYTHONPATH.  This is using Assembly.LoadFrom, and inherits all the
			    // caveats of that call.  See MSDN docs for details.
			    // Suzanne Cook's blog is also an excellent source of info on this:
			    // http://blogs.msdn.com/suzcook/
			    // http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx
			    // http://blogs.msdn.com/suzcook/archive/2003/06/13/57180.aspx

                var executingAssembly = System.Reflection.Assembly.GetExecutingAssembly();
                var assemblyDirectory = System.IO.Path.GetDirectoryName(executingAssembly.Location);
                if (assemblyDirectory == null)
                    throw new System.InvalidOperationException(executingAssembly.Location);
                var pythonRuntimeDllPath = System.IO.Path.Combine(assemblyDirectory, "Python.Runtime.dll");
#if DEBUG_PRINT
                System.Console.WriteLine("Attempting to load Python.Runtime from: '{0}'...", pythonRuntimeDllPath);
#endif
                pythonRuntime = System.Reflection.Assembly.LoadFrom(pythonRuntimeDllPath);
            }
            catch (System.InvalidOperationException) {
#if DEBUG_PRINT
                System.Console.WriteLine("Could not load Python.Runtime, so sad.");
#endif
                return;
            }
        }

        // Once here, we've successfully loaded SOME version of Python.Runtime
		// So now we get the PythonEngine and execute the InitExt method on it.
        var pythonEngineType = pythonRuntime.GetType("Python.Runtime.PythonEngine");
        pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null);
    }
コード例 #26
0
 public System.Reflection.Assembly LoadFromAssemblyName(System.Reflection.AssemblyName assemblyName)
 {
     throw new NotImplementedException();
 }
コード例 #27
0
 public static System.Reflection.Emit.AssemblyBuilder DefineDynamicAssembly(System.Reflection.AssemblyName name, System.Reflection.Emit.AssemblyBuilderAccess access, System.Collections.Generic.IEnumerable <System.Reflection.Emit.CustomAttributeBuilder> assemblyAttributes)
 {
     return(default(System.Reflection.Emit.AssemblyBuilder));
 }
コード例 #28
0
 public static void CompileToAssembly(System.Text.RegularExpressions.RegexCompilationInfo[] regexinfos, System.Reflection.AssemblyName assemblyname, System.Reflection.Emit.CustomAttributeBuilder[] attributes, string resourceFile)
 {
 }
コード例 #29
0
        private static System.Reflection.Assembly Default_Resolving(AssemblyLoadContext context, System.Reflection.AssemblyName assemblyName)
        {
            if (AzSharedAssemblyMap.ContainsKey(assemblyName.Name) && AzSharedAssemblyMap[assemblyName.Name] >= assemblyName.Version)
            {
                return(AzAssemblyLoadContext.GetForDirectory(AzSharedAssemblyDirectory).LoadFromAssemblyName(assemblyName));
            }

            if (ModuleAlcEntryAssemblyMap.TryGetValue(assemblyName.Name, out string moduleLoadContextDirectory))
            {
                return(AzAssemblyLoadContext.GetForDirectory(moduleLoadContextDirectory).LoadFromAssemblyPath(Path.Combine(moduleLoadContextDirectory, assemblyName.Name + ".dll")));
            }
            return(null);
        }
コード例 #30
0
 public System.Reflection.Assembly LoadFromAssemblyName(System.Reflection.AssemblyName assemblyName)
 {
     throw null;
 }
コード例 #31
0
 public override ModuleDesc ResolveAssembly(System.Reflection.AssemblyName name, bool throwIfNotFound)
 {
     // TODO: catch typesystem BadImageFormatException and throw a new one that also captures the
     // assembly name that caused the failure. (Along with the reason, which makes this rather annoying).
     return(GetModuleForSimpleName(name.Name, throwIfNotFound));
 }
コード例 #32
0
 public string ResolveAssemblyToPath(System.Reflection.AssemblyName assemblyName)
 {
     throw null;
 }
コード例 #33
0
 protected virtual System.Reflection.Assembly Load(System.Reflection.AssemblyName assemblyName)
 {
     throw null;
 }
コード例 #34
0
ファイル: Program.cs プロジェクト: littleking/DJK
        public static void Main()
        {
            Process instance = RunningInstance();

            if (instance == null)
            {
                //#if(!DEBUG)
                //                #region 检查升级
                //                try
                //                {

                //                    bool b = IsAppUpdate();
                //                    if (b)
                //                    {
                //                        //启动升级
                //                        ShellExecute(IntPtr.Zero, "Open", "AppUpdate.exe", null, Application.StartupPath, 1);
                //                        System.Diagnostics.Process.GetCurrentProcess().Kill();
                //                    }
                //                }
                //                catch (System.Exception ex)
                //                {
                //                    XtraMessageBox.Show("启动升级模块失败,请及时联系武汉威仕达软件工程有限公司");
                //                    return;
                //                }
                //                #endregion
                //#endif


                #region 捕获全局异常
                //设置应用程序处理异常方式:ThreadException处理
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                //处理UI线程异常
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                //处理非UI线程异常
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                #endregion

                try
                {
                    //第三方皮肤
                    DevExpress.UserSkins.BonusSkins.Register();
                    DevExpress.Skins.SkinManager.EnableFormSkins();
                }
                catch { }

                #region 应用程序的主入口点
                //调用“更换用户”的方法 执行以下代码报错
                if (!SysVar.IsChangeUser)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                }
                //获取客户端系统名称
                string strTitle = SettingHelper.ReadSetting("ClientTitle");
                //得到本地版本号
                System.Reflection.AssemblyName name = System.Reflection.AssemblyName.GetAssemblyName(SettingHelper.ReadSetting("ClientName"));
                string clientVersion = name.Version.ToString();
                //SysVar.SysTitle = strTitle + " " + clientVersion;
                SysVar.SysTitle = strTitle;
                //启动登陆
                //FrmLogin myLogin = new FrmLogin();

                //Starter starter = new Starter();
                //starter.Show();
                SysVar.IsChangeUser = true;
                SysVar.dtNow        = DateTime.Now;
                SysVar.dtOld        = DateTime.Now;

                SysVar.isLocal = false;
                //SysVar.isLocal = true;

                //FrmInfo frmM = new FrmInfo();
                //Application.Run(frmM);


                //SplashScreenManager.ShowForm(typeof(SplashStart));
                //Thread.Sleep(3000);
                //FrmInfo i = new FrmInfo();
                //FrmInfo.Instance = i;
                //SplashScreenManager.CloseForm();
                //Application.Run(i);
                FrmInfo i = new FrmInfo();
                FrmInfo.Instance = i;
                if (!SysVar.isLocal)
                {
                    FrmLogin myLogin = new FrmLogin();
                    if (myLogin.ShowDialog() != DialogResult.OK)
                    {
                        myLogin.Dispose();
                        Application.Exit();
                        return;
                    }
                }
                Application.Run(i);



                #endregion
            }
            else
            {
                HandleRunningInstance(instance);
            }
        }
コード例 #35
0
        private TypeForwarder HandleTypeForwarder(Cts.Ecma.EcmaModule module, Ecma.ExportedType exportedType)
        {
            Ecma.MetadataReader reader = module.MetadataReader;
            string        name         = reader.GetString(exportedType.Name);
            TypeForwarder result;

            switch (exportedType.Implementation.Kind)
            {
            case Ecma.HandleKind.AssemblyReference:
            {
                string ns = reader.GetString(exportedType.Namespace);
                NamespaceDefinition namespaceDefinition = HandleNamespaceDefinition(module, ns);

                Ecma.AssemblyReference assemblyRef = reader.GetAssemblyReference((Ecma.AssemblyReferenceHandle)exportedType.Implementation);
                AssemblyName           refName     = new AssemblyName
                {
                    ContentType = (AssemblyContentType)((int)(assemblyRef.Flags & AssemblyFlags.ContentTypeMask) >> 9),
                    Flags       = (AssemblyNameFlags)(assemblyRef.Flags & ~AssemblyFlags.ContentTypeMask),
                    CultureName = reader.GetString(assemblyRef.Culture),
                    Name        = reader.GetString(assemblyRef.Name),
                    Version     = assemblyRef.Version,
                };

                if ((assemblyRef.Flags & AssemblyFlags.PublicKey) != 0)
                {
                    refName.SetPublicKey(reader.GetBlobBytes(assemblyRef.PublicKeyOrToken));
                }
                else
                {
                    refName.SetPublicKeyToken(reader.GetBlobBytes(assemblyRef.PublicKeyOrToken));
                }

                result = new TypeForwarder
                {
                    Name  = HandleString(name),
                    Scope = HandleScopeReference(refName),
                };

                namespaceDefinition.TypeForwarders.Add(result);
            }
            break;

            case Ecma.HandleKind.ExportedType:
            {
                TypeForwarder scope = HandleTypeForwarder(module, reader.GetExportedType((Ecma.ExportedTypeHandle)exportedType.Implementation));

                result = new TypeForwarder
                {
                    Name  = HandleString(name),
                    Scope = scope.Scope,
                };

                scope.NestedTypes.Add(result);
            }
            break;

            default:
                throw new BadImageFormatException();
            }

            return(result);
        }
コード例 #36
0
 public override ModuleDesc ResolveAssembly(System.Reflection.AssemblyName name, bool throwIfNotFound)
 {
     return(GetModuleForSimpleName(name.Name));
 }
コード例 #37
0
ファイル: MiniAssembly.cs プロジェクト: JianwenSun/cc
        public MiniAssembly ResolveAssemblyRef(MetadataToken token, bool throwOnError)
        {
            System.Diagnostics.Contracts.Contract.Requires(token.Table == MDTables.Tables.AssemblyRef);
            PEFileReader peFile = this.PEFileReader;
            MDTables metaData = peFile.MetaData;

            metaData.SeekToMDToken(token);
            peFile.B.ReadUInt64();  // Skip 4 parts of the version number.
            peFile.B.ReadUInt32();  // AssemblyFlags
            byte[] publicKeyOrToken = metaData.ReadBlob(); // Public key or token
            String assemblySimpleName = metaData.ReadString(); // simple name
            String cultureName = metaData.ReadString();  // assembly culture
            if (!String.IsNullOrEmpty(cultureName))
                throw new BadImageFormatException(Res.UnexpectedlyLoadingASatellite, FullName);

            if (assemblySimpleName == "mscorlib" && (cultureName.Length == 0 || cultureName == "neutral"))
                return new MiniAssembly(typeof(Object).Assembly);

            MiniAssembly loadedAssembly = Open(assemblySimpleName, _dependencyDirs, throwOnError);

            if (loadedAssembly != null)
            {
                // Check whether the reference to the assembly matches what we actually loaded.
                // We don't respect the "throwOnError" parameter here because if someone does
                // violate this, they've either severely messed up their deployment, or they're
                // attempting a security exploit.
                System.Reflection.AssemblyName loadedAssemblyName = 
                    new System.Reflection.AssemblyName(loadedAssembly.FullName);

                if (!Utils.PublicKeyMatches(loadedAssemblyName, publicKeyOrToken))
                {
                    throw new FileLoadException(String.Format(CultureInfo.CurrentCulture, Res.AssemblyLoadRefDefMismatch, 
                        assemblySimpleName, publicKeyOrToken, loadedAssemblyName.GetPublicKeyToken()));
                }

                if (!String.IsNullOrEmpty(loadedAssemblyName.CultureInfo.Name))
                {
                    throw new FileLoadException(String.Format(CultureInfo.CurrentCulture, Res.AssemblyLoadRefDefMismatch,
                        assemblySimpleName, String.Empty, loadedAssemblyName.CultureInfo.Name));
                }
            }
            return loadedAssembly;
        }
コード例 #38
0
ファイル: Linq2AzureDriver.cs プロジェクト: AntoineGa/API
 public override List<ExplorerItem> GetSchemaAndBuildAssembly(IConnectionInfo cxInfo, System.Reflection.AssemblyName assemblyToBuild, ref string nameSpace, ref string typeName)
 {
     return SchemaBuilder.GetSchemaAndBuildAssembly(new Linq2AzureProperties(cxInfo), assemblyToBuild, ref nameSpace, ref typeName);
 }
コード例 #39
0
ファイル: SettingsBase.cs プロジェクト: knocte/BuildAMation
        SharedSettings(
            System.Collections.Generic.IEnumerable<Bam.Core.Module> objectFiles,
            System.Type convertExtensionClassType,
            System.Type conversionInterfaceType,
            Bam.Core.TypeArray convertParameterTypes)
        {
            var sharedInterfaces = SharedInterfaces(objectFiles);
            var implementedInterfaces = new Bam.Core.TypeArray(sharedInterfaces);
            implementedInterfaces.Add(conversionInterfaceType);

            // define a new type, that contains just the shared interfaces between all object files
            // (any interface not shared, must be cloned later)
            var typeSignature = "IDESharedSettings";
            var assemblyName = new System.Reflection.AssemblyName(typeSignature);
            var assemblyBuilder = System.AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, System.Reflection.Emit.AssemblyBuilderAccess.Run);
            var moduleBuilder = assemblyBuilder.DefineDynamicModule("MainModule", true);
            var sharedSettingsTypeDefn = moduleBuilder.DefineType(typeSignature,
                System.Reflection.TypeAttributes.Public |
                System.Reflection.TypeAttributes.Class |
                System.Reflection.TypeAttributes.AutoClass |
                System.Reflection.TypeAttributes.AnsiClass |
                System.Reflection.TypeAttributes.BeforeFieldInit |
                System.Reflection.TypeAttributes.AutoLayout,
                typeof(C.SettingsBase),
                implementedInterfaces.ToArray());

                // TODO: is this necessary?
#if false
            sharedSettingsTypeDefn.DefineDefaultConstructor(
                System.Reflection.MethodAttributes.Public | System.Reflection.MethodAttributes.SpecialName | System.Reflection.MethodAttributes.RTSpecialName);
#endif

            // implement 'automatic property' setter and getters for each property in each interface
            foreach (var i in sharedInterfaces)
            {
                var properties = i.GetProperties();
                foreach (var prop in properties)
                {
                    var dynamicProperty = sharedSettingsTypeDefn.DefineProperty(prop.Name,
                        System.Reflection.PropertyAttributes.None,
                        prop.PropertyType,
                        System.Type.EmptyTypes);
                    var field = sharedSettingsTypeDefn.DefineField("m" + prop.Name,
                        prop.PropertyType,
                        System.Reflection.FieldAttributes.Private);
                    var methodAttrs = System.Reflection.MethodAttributes.Public |
                        System.Reflection.MethodAttributes.HideBySig |
                        System.Reflection.MethodAttributes.Virtual;
                    if (prop.IsSpecialName)
                    {
                        methodAttrs |= System.Reflection.MethodAttributes.SpecialName;
                    }
                    var getter = sharedSettingsTypeDefn.DefineMethod("get_" + prop.Name,
                        methodAttrs,
                        prop.PropertyType,
                        System.Type.EmptyTypes);
                    var setter = sharedSettingsTypeDefn.DefineMethod("set_" + prop.Name,
                        methodAttrs,
                        null,
                        new[] { prop.PropertyType });
                    var getIL = getter.GetILGenerator();
                    getIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_0);
                    getIL.Emit(System.Reflection.Emit.OpCodes.Ldfld, field);
                    getIL.Emit(System.Reflection.Emit.OpCodes.Ret);
                    dynamicProperty.SetGetMethod(getter);
                    var setIL = setter.GetILGenerator();
                    setIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_0);
                    setIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_1);
                    setIL.Emit(System.Reflection.Emit.OpCodes.Stfld, field);
                    setIL.Emit(System.Reflection.Emit.OpCodes.Ret);
                    dynamicProperty.SetSetMethod(setter);
                }
            }

            var projectSettingsConvertMethod = sharedSettingsTypeDefn.DefineMethod("Convert",
                System.Reflection.MethodAttributes.Public | System.Reflection.MethodAttributes.Final | System.Reflection.MethodAttributes.HideBySig | System.Reflection.MethodAttributes.NewSlot | System.Reflection.MethodAttributes.Virtual,
                null,
                convertParameterTypes.ToArray());
            var convertIL = projectSettingsConvertMethod.GetILGenerator();
            foreach (var i in sharedInterfaces)
            {
                var extConvertParameterTypes = new Bam.Core.TypeArray(i);
                extConvertParameterTypes.AddRange(convertParameterTypes);
                var methInfo = convertExtensionClassType.GetMethod("Convert", extConvertParameterTypes.ToArray());
                if (null == methInfo)
                {
                        throw new Bam.Core.Exception("Unable to locate the function {0}.{1}(this {2})", convertExtensionClassType.FullName, "Convert", i.Name);
                }
                // TODO: can this be simplified, using the ldarg opcode? a simple loop would suffice
                convertIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_0);
                if (extConvertParameterTypes.Count > 1)
                {
                    convertIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_1);
                }
                if (extConvertParameterTypes.Count > 2)
                {
                    convertIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_2);
                }
                if (extConvertParameterTypes.Count > 3)
                {
                    convertIL.Emit(System.Reflection.Emit.OpCodes.Ldarg_3);
                }
                convertIL.Emit(System.Reflection.Emit.OpCodes.Call, methInfo);
            }
            convertIL.Emit(System.Reflection.Emit.OpCodes.Ret);

            var sharedSettingsType = sharedSettingsTypeDefn.CreateType();
            var attributeType = typeof(Bam.Core.SettingsExtensionsAttribute);

            // now that we have an instance of the shared settings type, calculate the values of the individual settings across all object files
            // for all shared interfaces
            var commonSettings = System.Activator.CreateInstance(sharedSettingsType) as SettingsBase;
            commonSettings.InitializeAllInterfaces(objectFiles.First(), true, false);
            foreach (var i in sharedInterfaces)
            {
                var attributeArray = i.GetCustomAttributes(attributeType, false);
                if (0 == attributeArray.Length)
                {
                    throw new Bam.Core.Exception("Settings interface {0} is missing attribute {1}", i.ToString(), attributeType.ToString());
                }

                var attribute = attributeArray[0] as Bam.Core.SettingsExtensionsAttribute;

                var cloneSettingsMethod = attribute.GetMethod("Clone", new[] { i, i });
                if (null == cloneSettingsMethod)
                {
                    throw new Bam.Core.Exception("Unable to find extension method {0}.SharedSettings(this {1}, {1}, {1}, {1})",
                        attribute.ExtensionsClassName,
                        i.ToString());
                }

                var intersectSettingsMethod = attribute.GetMethod("Intersect", new[] { i, i });
                if (null == intersectSettingsMethod)
                {
                    throw new Bam.Core.Exception("Unable to find extension method {0}.Intersect(this {1}, {1})",
                        attribute.ExtensionsClassName,
                        i.ToString());
                }

                var objectFileCount = objectFiles.Count();
                cloneSettingsMethod.Invoke(null, new[] { commonSettings, objectFiles.First().Settings });
                for (int objIndex = 1; objIndex < objectFileCount; ++objIndex)
                {
                    intersectSettingsMethod.Invoke(null, new[] { commonSettings, objectFiles.ElementAt(objIndex).Settings });
                }
            }
            return commonSettings;
        }
コード例 #40
0
 System.Reflection.Emit.AssemblyBuilder _AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName name, System.Reflection.Emit.AssemblyBuilderAccess access)
 {
     throw new Exception("The method or operation is not implemented.");
 }
コード例 #41
0
        /// <summary>
        /// Parses the string '<paramref name="name"/>' and returns the type corresponding to the parsed type name.
        /// The type name string should be in the 'SerString' format as defined by the ECMA-335 standard.
        /// This is the inverse of what <see cref="CustomAttributeTypeNameFormatter"/> does.
        /// </summary>
        public static TypeDesc GetTypeByCustomAttributeTypeName(this ModuleDesc module, string name, bool throwIfNotFound = true, Func <string, ModuleDesc, bool, MetadataType> resolver = null)
        {
            TypeDesc loadedType;

            StringBuilder genericTypeDefName = new StringBuilder(name.Length);

            var ch      = name.Begin();
            var nameEnd = name.End();

            for (; ch < nameEnd; ++ch)
            {
                // Always pass escaped characters through.
                if (ch.Current == '\\')
                {
                    genericTypeDefName.Append(ch.Current);
                    ++ch;
                    if (ch < nameEnd)
                    {
                        genericTypeDefName.Append(ch.Current);
                    }
                    continue;
                }

                // The type def name ends if

                // The start of a generic argument list
                if (ch.Current == '[')
                {
                    break;
                }

                // Indication that the type is a pointer
                if (ch.Current == '*')
                {
                    break;
                }

                // Indication that the type is a reference
                if (ch.Current == '&')
                {
                    break;
                }

                // A comma that indicates that the rest of the name is an assembly reference
                if (ch.Current == ',')
                {
                    break;
                }

                genericTypeDefName.Append(ch.Current);
            }

            ModuleDesc   homeModule   = module;
            AssemblyName homeAssembly = FindAssemblyIfNamePresent(name);

            if (homeAssembly != null)
            {
                homeModule = module.Context.ResolveAssembly(homeAssembly);
            }
            MetadataType typeDef = resolver != null?resolver(genericTypeDefName.ToString(), homeModule, throwIfNotFound) :
                                       ResolveCustomAttributeTypeDefinitionName(genericTypeDefName.ToString(), homeModule, throwIfNotFound);

            if (typeDef == null)
            {
                return(null);
            }

            ArrayBuilder <TypeDesc> genericArgs = new ArrayBuilder <TypeDesc>();

            // Followed by generic instantiation parameters (but check for the array case)
            if (ch < nameEnd && ch.Current == '[' && (ch + 1) < nameEnd && (ch + 1).Current != ']' && (ch + 1).Current != ',')
            {
                ch++;                                                                   // truncate the '['
                var genericInstantiationEnd = ch + ReadTypeArgument(ch, nameEnd, true); // find the end of the instantiation list
                while (ch < genericInstantiationEnd)
                {
                    if (ch.Current == ',')
                    {
                        ch++;
                    }

                    int    argLen = ReadTypeArgument(ch, name.End(), false);
                    string typeArgName;
                    if (ch.Current == '[')
                    {
                        // This type argument name is stringified,
                        // we need to remove the [] from around it
                        ch++;
                        typeArgName = StringIterator.Substring(ch, ch + (argLen - 2));
                        ch         += argLen - 1;
                    }
                    else
                    {
                        typeArgName = StringIterator.Substring(ch, ch + argLen);
                        ch         += argLen;
                    }

                    TypeDesc argType = module.GetTypeByCustomAttributeTypeName(typeArgName, throwIfNotFound, resolver);
                    if (argType == null)
                    {
                        return(null);
                    }
                    genericArgs.Add(argType);
                }

                Debug.Assert(ch == genericInstantiationEnd);
                ch++;

                loadedType = typeDef.MakeInstantiatedType(genericArgs.ToArray());
            }
            else
            {
                // Non-generic type
                loadedType = typeDef;
            }

            // At this point the characters following may be any number of * characters to indicate pointer depth
            while (ch < nameEnd)
            {
                if (ch.Current == '*')
                {
                    loadedType = loadedType.MakePointerType();
                }
                else
                {
                    break;
                }
                ch++;
            }

            // Followed by any number of "[]" or "[,*]" pairs to indicate arrays
            int  commasSeen  = 0;
            bool bracketSeen = false;

            while (ch < nameEnd)
            {
                if (ch.Current == '[')
                {
                    ch++;
                    commasSeen  = 0;
                    bracketSeen = true;
                }
                else if (ch.Current == ']')
                {
                    if (!bracketSeen)
                    {
                        break;
                    }

                    ch++;
                    if (commasSeen == 0)
                    {
                        loadedType = loadedType.MakeArrayType();
                    }
                    else
                    {
                        loadedType = loadedType.MakeArrayType(commasSeen + 1);
                    }

                    bracketSeen = false;
                }
                else if (ch.Current == ',')
                {
                    if (!bracketSeen)
                    {
                        break;
                    }
                    ch++;
                    commasSeen++;
                }
                else
                {
                    break;
                }
            }

            // Followed by at most one & character to indicate a byref.
            if (ch < nameEnd)
            {
                if (ch.Current == '&')
                {
                    loadedType = loadedType.MakeByRefType();
                    ch++;
                }
            }

            return(loadedType);
        }
コード例 #42
0
 System.Reflection.Assembly _AppDomain.Load(System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity)
 {
     throw new Exception("The method or operation is not implemented.");
 }
コード例 #43
0
        private void LlamarFormulario()
        {
            try
            {
                //if (sender.GetType() == typeof(TreeView))
                //{
                //string NombreFormulario = ((TreeView)sender).Tag.ToString();


                if (infoMenu.Tiene_FormularioAsociado == false)
                {
                    return;
                }

                string NombreFormulario = infoMenu.nom_Formulario;
                string Nombre_Asamble   = infoMenu.nom_Asembly;
                string nombre_dll       = "";

                string RutaPantalla = "";

                nombre_dll = Nombre_Asamble;
                System.Reflection.Assembly Ensamblado;
                Ensamblado = System.Reflection.Assembly.LoadFrom(nombre_dll);
                System.Reflection.AssemblyName assemName = Ensamblado.GetName();
                Version ver = assemName.Version;

                Object ObjFrm;
                Type   tipo = Ensamblado.GetType(assemName.Name + "." + NombreFormulario);



                //

                RutaPantalla = assemName.Name + "." + NombreFormulario;


                if (tipo == null)
                {
                    MessageBox.Show("No se encontró el formulario Emsamblado:" + Nombre_Asamble + "  Formulario:" + NombreFormulario, "Error de ubicación", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    if (!this.FormularioEstaAbierto(NombreFormulario))
                    {
                        ObjFrm = Activator.CreateInstance(tipo);
                        Form Formulario = (Form)ObjFrm;
                        Formulario.Text = infoMenu.DescripcionMenu + " Version:" + ver.ToString();

                        Formulario.MdiParent   = (Form)this.ParentForm;
                        Formulario.Tag         = infoMenu;
                        Formulario.WindowState = FormWindowState.Maximized;
                        Formulario.Show();
                    }
                }
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #44
0
 private static bool IsMSBuildAssembly(System.Reflection.AssemblyName assemblyName)
 {
     return(s_msBuildAssemblies.Contains(assemblyName.Name, StringComparer.OrdinalIgnoreCase));
 }
コード例 #45
0
ファイル: CustomCommand.cs プロジェクト: smallwave/PTVS
 private static string LoadResourceFromAssembly(string assembly, string ns, string key) {
     try {
         var asmName = new System.Reflection.AssemblyName(assembly);
         System.Reflection.Assembly asm = null;
         if (asmName.FullName == asmName.Name) {
             // A partial name was provided. If there is an assembly with
             // matching name in the current AppDomain, assume that is
             // the intended one.
             asm = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => assembly == a.GetName().Name);
         }
         
         asm = asm ?? System.Reflection.Assembly.Load(asmName);
         var rm = new System.Resources.ResourceManager(ns, asm);
         return rm.GetString(key, CultureInfo.CurrentUICulture) ?? key;
     } catch (Exception ex) {
         ActivityLog.LogError(Strings.ProductTitle, Strings.FailedToReadResource.FormatUI(assembly, ns, key, ex));
         return key;
     }
 }
コード例 #46
0
 public System.Reflection.Assembly LoadFromAssemblyName(System.Reflection.AssemblyName assemblyName)
 {
     return(default(System.Reflection.Assembly));
 }
コード例 #47
0
    internal HostEnvironment()
      : base(new NameTable(), new InternFactory(), 0, null, true) {
      this.peReader = new PeReader(this);
      string/*?*/ loc = typeof(object).Assembly.Location;
      if (loc == null) loc = "";
      System.Reflection.AssemblyName coreAssemblyName = new System.Reflection.AssemblyName(typeof(object).Assembly.FullName);
      this.coreAssemblySymbolicIdentity =
        new AssemblyIdentity(this.NameTable.GetNameFor(coreAssemblyName.Name), "", coreAssemblyName.Version, coreAssemblyName.GetPublicKeyToken(), loc);
      this.RegisterAsLatest(this.peReader.OpenAssembly(BinaryDocument.GetBinaryDocumentForFile(loc, this)));
      loc = typeof(Microsoft.SmallBasic.Library.ConsoleTextColor).Assembly.Location;
      if (loc == null) loc = "";
      //System.Reflection.AssemblyName runtimeName = new System.Reflection.AssemblyName(typeof(Microsoft.SmallBasic.Library.ConsoleTextColor).Assembly.FullName);
      //this.smallBasicRuntimeAssemblyIdentity =
      //  new AssemblyIdentity(this.NameTable.GetNameFor(runtimeName.Name), "", runtimeName.Version, runtimeName.GetPublicKeyToken(), loc);
      this.RegisterAsLatest(this.peReader.OpenAssembly(BinaryDocument.GetBinaryDocumentForFile(loc, this)));

    }
コード例 #48
0
ファイル: AboutDialog.cs プロジェクト: abdullah-19/megaide
        /// <summary>
        /// Required designer variable.
        /// </summary>

        private AboutDialogClass()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();
            userNameLabel.Text     = System.Environment.UserName;
            computerNameLabel.Text = System.Environment.MachineName;

            OperatingSystem osInfo = Environment.OSVersion;
            string          osName = "UNKNOWN";

            switch (osInfo.Platform)
            {
            case PlatformID.Win32Windows:
            {
                switch (osInfo.Version.Minor)
                {
                case 0:
                {
                    osName = "Windows 95";
                    break;
                }

                case 10:
                {
                    if (osInfo.Version.Revision.ToString() == "2222A")
                    {
                        osName = "Windows 98 SE";
                    }
                    else
                    {
                        osName = "Windows 98";
                    }
                    break;
                }

                case 90:
                {
                    osName = "Windows Me";
                    break;
                }
                }
                break;
            }

            case PlatformID.Win32NT:
            {
                switch (osInfo.Version.Major)
                {
                case 3:
                {
                    osName = "Windows NT 3.51";
                    break;
                }

                case 4:
                {
                    osName = "Windows NT 4.0";
                    break;
                }

                case 5:
                {
                    if (osInfo.Version.Minor == 0)
                    {
                        osName = "Windows 2000";
                    }
                    else if (osInfo.Version.Minor == 1)
                    {
                        osName = "Windows XP";
                    }
                    else if (osInfo.Version.Minor == 2)
                    {
                        osName = "Windows Server 2003";
                    }
                    break;
                }

                case 6:
                {
                    osName = "Windows Vista";
                    break;
                }
                }
                break;
            }
            }
            osLabel.Text = "Operating System : " + osName;
            NETXP.Win32.API.MEMORYSTATUS memoryStatus = new NETXP.Win32.API.MEMORYSTATUS();
            NETXP.Win32.API.GlobalMemoryStatus(memoryStatus);
            memoryLabel.Text   = "Physical Memory : " + (memoryStatus.dwTotalPhys / (1023 * 1023)).ToString("0 MB");
            assemblyLabel.Text = "Total " + AppDomain.CurrentDomain.GetAssemblies().Length + " assemblies loaded !";
            foreach (System.Reflection.Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                System.Reflection.AssemblyName assemblyName = assembly.GetName();
                ListViewItem assemblyItem;
                if (assemblyName.Name == "MegaIDE")
                {
                    versionLabel.Text = "Version : " + assemblyName.Version.Major + "." + assemblyName.Version.Minor + "    Build : " + assemblyName.Version.Build.ToString() + "    Revision : " + assemblyName.Version.Revision;
                }
                if (assemblyName.GetPublicKeyToken() != null)
                {
                    assemblyItem = new ListViewItem(new String[] { assemblyName.Name, assemblyName.Version.ToString(), ToHexString(assemblyName.GetPublicKeyToken()) }, 0);
                }
                else
                {
                    assemblyItem = new ListViewItem(new String[] { assemblyName.Name, assemblyName.Version.ToString(), "null" }, 0);
                }
                assemblyList.Items.Add(assemblyItem);
            }
            assemblyList.Columns[0].Width = -1;
            assemblyList.Columns[1].Width = -1;
            assemblyList.Columns[2].Width = -2;
        }
コード例 #49
0
 public static System.Reflection.Emit.AssemblyBuilder DefineDynamicAssembly(System.Reflection.AssemblyName name, System.Reflection.Emit.AssemblyBuilderAccess access)
 {
     return(default(System.Reflection.Emit.AssemblyBuilder));
 }
コード例 #50
0
 public abstract System.Reflection.Assembly?Resolve(System.Reflection.MetadataLoadContext context, System.Reflection.AssemblyName assemblyName);
コード例 #51
0
ファイル: GamePage.xaml.cs プロジェクト: thesourcerer/WazeWP7
        public String GetAppVersion()
        {
            string name = System.Reflection.Assembly.GetExecutingAssembly().FullName;
            System.Reflection.AssemblyName asmName = new System.Reflection.AssemblyName(name);

            //System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
            Version version = asmName.Version;
            String s = String.Format("{0}.{1}.{2}.{3}",
                                                version.Major,
                                                version.Minor,
                                                version.Build,
                                                version.Revision);
            return s;
        }
コード例 #52
0
        /// <summary>
        /// Loads a .resx file (given a stream with it's content) into the given <see cref="ResourceSet"/>
        /// </summary>
        internal static void Resx2ResourceSet(ResourceSet resourceSet, Stream stream)
        {
            ResourceItem       resourceItem;
            ResourceStringItem resourceStringItem;
            string             resourceComment;
            ResXDataNode       res;
            object             value;
            var reader = new ResXResourceReader(stream);

            reader.UseResXDataNodes = true;

            var assemblyNames = new System.Reflection.AssemblyName[] { };   // this is used as parameter of GetValue since there is no overload that accepts no parameter

            foreach (DictionaryEntry item in reader)
            {
                res = (ResXDataNode)item.Value;

                // resource item has file reference then special care must be taken
                if (res.FileRef == null)
                {
                    value = res.GetValue(assemblyNames);
                }
                else
                {
                    value = res.FileRef;
                }

                resourceComment = res.Comment;

                int sharpPosition = -1;
                if (!string.IsNullOrEmpty(resourceComment))
                {
                    sharpPosition = resourceComment.IndexOf("#", StringComparison.OrdinalIgnoreCase);
                }

                if (resourceComment == null)
                {
                    resourceComment = string.Empty;
                }

                if (value != null)
                {
                    switch (value.GetType().Name)
                    {
                    case "String":
                        resourceStringItem = new ResourceStringItem();
                        resourceItem       = resourceStringItem;

                        if (sharpPosition > 0)
                        {
                            int tempValue;

                            if (int.TryParse(resourceComment.Substring(0, sharpPosition), out tempValue))
                            {
                                resourceStringItem.MaxLength = tempValue;
                                resourceComment = resourceComment.Substring(sharpPosition + 1);
                            }
                        }

                        break;

                    default:
                        resourceItem = new ResourceItem();
                        break;
                    }
                }
                else
                {
                    resourceItem = new ResourceItem();
                }

                resourceItem.Name  = res.Name;
                resourceItem.Value = value;
                LockedReason resourceLockedReason = LockedReason.Unknown;

                // lock local value if base comment begins with #
                bool resourceLocked;
                if (sharpPosition == 0)
                {
                    resourceLocked       = true;
                    resourceLockedReason = LockedReason.DeveloperLock;
                    resourceComment      = resourceComment.Substring(1);
                }
                else
                {
                    resourceLocked = false;
                }

                if (resourceItem.Name.StartsWith(">>", StringComparison.OrdinalIgnoreCase))
                {
                    resourceLocked       = true;
                    resourceLockedReason = LockedReason.FrameworkLock;
                }

                if (resourceComment.StartsWith("@", StringComparison.OrdinalIgnoreCase))
                {
                    resourceLocked       = true;
                    resourceLockedReason = LockedReason.ResexMetadata;
                }

                if (resourceComment.StartsWith("?", StringComparison.OrdinalIgnoreCase))
                {
                    resourceComment            = resourceComment.Substring(1);
                    resourceItem.ReviewPending = true;
                }

                resourceItem.Comment      = resourceComment;
                resourceItem.Locked       = resourceLocked;
                resourceItem.LockedReason = resourceLockedReason;

                // add item to collection
                resourceSet.Add(resourceItem.Name, resourceItem);
            }
        }
コード例 #53
0
 private static System.Reflection.Assembly Default_Resolving(AssemblyLoadContext arg1, System.Reflection.AssemblyName arg2)
 {
     return(arg1.LoadFromAssemblyName(arg2));
 }
コード例 #54
0
 protected abstract System.Reflection.Assembly Load(System.Reflection.AssemblyName assemblyName);
コード例 #55
0
        /// <summary>
        /// Using reflection, enumerate all assemblies in the current appdomain looking for classes that
        /// have a SqliteFunctionAttribute attribute, and registering them accordingly.
        /// </summary>
#if !PLATFORM_COMPACTFRAMEWORK
        // [global::System.Security.Permissions.FileIOPermission(global::System.Security.Permissions.SecurityAction.Assert, AllFiles = global::System.Security.Permissions.FileIOPermissionAccess.PathDiscovery)]
#endif
        static SqliteFunction()
        {
            try
            {
#if !PLATFORM_COMPACTFRAMEWORK
                SqliteFunctionAttribute      at;
                System.Reflection.Assembly[] arAssemblies = System.AppDomain.CurrentDomain.GetAssemblies();
                int w = arAssemblies.Length;
                System.Reflection.AssemblyName sqlite = System.Reflection.Assembly.GetCallingAssembly().GetName();

                for (int n = 0; n < w; n++)
                {
                    Type[] arTypes;
                    bool   found = false;
                    System.Reflection.AssemblyName[] references;
                    try
                    {
                        // Inspect only assemblies that reference SQLite
                        references = arAssemblies[n].GetReferencedAssemblies();
                        int t = references.Length;
                        for (int z = 0; z < t; z++)
                        {
                            if (references[z].Name == sqlite.Name)
                            {
                                found = true;
                                break;
                            }
                        }

                        if (found == false)
                        {
                            continue;
                        }

                        arTypes = arAssemblies[n].GetTypes();
                    }
                    catch (global::System.Reflection.ReflectionTypeLoadException e)
                    {
                        arTypes = e.Types;
                    }

                    int v = arTypes.Length;
                    for (int x = 0; x < v; x++)
                    {
                        if (arTypes[x] == null)
                        {
                            continue;
                        }

                        object[] arAtt = arTypes[x].GetCustomAttributes(typeof(SqliteFunctionAttribute), false);
                        int      u     = arAtt.Length;
                        for (int y = 0; y < u; y++)
                        {
                            at = arAtt[y] as SqliteFunctionAttribute;
                            if (at != null)
                            {
                                at._instanceType = arTypes[x];
                                _registeredFunctions.Add(at);
                            }
                        }
                    }
                }
#endif
            }
            catch // SQLite provider can continue without being able to find built-in functions
            {
            }
        }
コード例 #56
0
 public static System.Reflection.Assembly Load(System.Reflection.AssemblyName assemblyRef)
 {
     return(default(System.Reflection.Assembly));
 }
コード例 #57
0
 public override System.Reflection.Assembly? Resolve(System.Reflection.MetadataLoadContext context, System.Reflection.AssemblyName assemblyName)
 {
     throw null;
 }
コード例 #58
0
 public static void CompileToAssembly(System.Text.RegularExpressions.RegexCompilationInfo[] regexinfos, System.Reflection.AssemblyName assemblyname)
 {
 }
コード例 #59
0
 public static System.Collections.ICollection GetToolboxItems(System.Reflection.AssemblyName an, bool throwOnError)
 {
     throw null;
 }
コード例 #60
0
 protected override System.Reflection.Assembly Load(System.Reflection.AssemblyName assemblyName)
 {
     throw new NotImplementedException();
 }