Inheritance: ICloneable, ISerializable, IDeserializationCallback, _AssemblyName
示例#1
0
        public CodeGenerator(Expression pExpression, String pModuleName, ref LogHandler rLogHandler)
        {
            _symbolTable  = new Dictionary <String, Emit.LocalBuilder>();
            _assemblyName = new Reflect.AssemblyName(Path.GetFileNameWithoutExtension(pModuleName));

            _statement = pExpression;

            //Init Assembly
            _assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(_assemblyName, Emit.AssemblyBuilderAccess.Save);
            _moduleBuilder   = _assemblyBuilder.DefineDynamicModule(pModuleName);
            _typeBuilder     = _moduleBuilder.DefineType("PascalCompilerType");
            _methodBuilder   = _typeBuilder.DefineMethod
                               (
                "Main",
                Reflect.MethodAttributes.Static,
                typeof(void),
                Type.EmptyTypes
                               );
            _ilGenerator = _methodBuilder.GetILGenerator();

            //Actual Work
            GenerateStatement(_statement, null);
            _ilGenerator.Emit(Emit.OpCodes.Ret);

            //Finalizing Work
            _typeBuilder.CreateType();
            _moduleBuilder.CreateGlobalFunctions();
            _assemblyBuilder.SetEntryPoint(_methodBuilder);
            _assemblyBuilder.Save(pModuleName);
        }
示例#2
0
        private static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
        {
            lock (syncRoot)
            {
                if (checkedAssemblies.Add(args.Name))
                {
                    var assemblyName = new AssemblyName(args.Name);
                    if (!assemblyName.Name.EndsWith(".resources"))
                    {
                        var stream = typeof(AssemblyResolver).Assembly.GetManifestResourceStream(typeof(AssemblyResolver), assemblyName.Name + ".pkg");
                        if (stream != null)
                        {
                            using (var package = Package.Open(stream))
                            {
                                var partUri = PackUriHelper.CreatePartUri(new Uri(assemblyName.Name + ".dll", UriKind.Relative));
                                if (package.PartExists(partUri))
                                {
                                    var part = package.GetPart(partUri);
                                    var ms = new MemoryStream();
                                    part.GetStream().CopyTo(ms);
                                    return Assembly.Load(ms.ToArray());
                                }
                            }
                        }
                    }
                }

                return null;
            }
        }
        // .NET core does not contain the GetExecutingAssembly() method so we must pass in a reference to the entry assembly
        public static void UseInfoEndpoint(this IApplicationBuilder app, AssemblyName entryAssembly)
        {
            app.Use(async (context, next) =>
            {
                if (context.Request.Path.Value.Equals("/info"))
                {
                    // Perform IP access check
                    if (MicroserviceConfiguration.AllowedIpAddresses != null && context.Request.HttpContext.Connection.RemoteIpAddress != null)
                    {
                        if (!MicroserviceConfiguration.AllowedIpAddresses.Contains(context.Request.HttpContext.Connection.RemoteIpAddress))
                        {
                            context.Response.StatusCode = 403;
                            await next();
                        }
                    }

                    var appInfo = new
                    {
                        Name = entryAssembly.Name,
                        Version = entryAssembly.Version.ToString(3)
                    };

                    context.Response.Headers["Content-Type"] = "application/json";
                    await context.Response.WriteAsync(JsonConvert.SerializeObject(appInfo));
                }
                else
                {
                    await next();
                }
            });
        }
示例#4
0
文件: CodeGen.cs 项目: ypyf/Clound
        private void Compile(Ast ast, string fileName)
        {
            string asmFileName = fileName + ".exe";

            // 定义程序集(表示可执行文件)
            Reflect.AssemblyName name = new Reflect.AssemblyName(fileName);

            // 从当前域获取动态编译生成器
            AssemblyBuilder asmb = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.Save);

            // 获取模块生成器
            // 注意,exe的模块名必须和生成的可执行文件同名
            myModule = asmb.DefineDynamicModule(asmFileName);

            // 获取类生成器 (将作为Main所在的类)
            TypeBuilder typeBuilder = myModule.DefineType(fileName, Reflect.TypeAttributes.UnicodeClass);

            // 方法生成器(生成Main函数作为入口点)
            MethodBuilder methb = typeBuilder.DefineMethod("Main", Reflect.MethodAttributes.Static, typeof(void), Type.EmptyTypes);

            // 获取代码生成器
            ILGenerator il = methb.GetILGenerator();

            // 创建全局环境
            Env globals = new Env();

            // 生成代码
            GenASTree(ast, globals, il);

            il.Emit(OpCodes.Ret);
            typeBuilder.CreateType();
            myModule.CreateGlobalFunctions();
            asmb.SetEntryPoint(methb, PEFileKinds.ConsoleApplication);
            asmb.Save(asmFileName);
        }
示例#5
0
        public frmMainSheet()
        {
            //https://stackoverflow.com/a/6362414/1764583
            //https://stackoverflow.com/a/27280598/1764583
            // To embed a dll in a compiled exe:
            // 1 - Change the properties of the dll in References so that Copy Local=false
            // 2 - Add the dll file to the project as an additional file not just a reference
            // 3 - Change the properties of the file so that Build Action=Embedded Resource
            // 4 - Paste this code before Application.Run in the main exe
            AppDomain.CurrentDomain.AssemblyResolve += (Object sender, ResolveEventArgs args) =>
            {
                String thisExe = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
                System.Reflection.AssemblyName embeddedAssembly = new System.Reflection.AssemblyName(args.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));
                }
            };

            InitializeComponent();
        }
示例#6
0
        public static Assembly ResolveAssembly(object sender, ResolveEventArgs args)
        {
            var name = new AssemblyName(args.Name).Name.ToLowerInvariant();
            var existingAssembly = ReadExistingAssembly(name);
            if (existingAssembly != null)
            {
                return existingAssembly;
            }

            var prefix = string.Concat("costura.", name);
            var executingAssembly = Assembly.GetExecutingAssembly();

            byte[] assemblyData;
            using (var assemblyStream = GetAssemblyStream(executingAssembly, prefix))
            {
                if (assemblyStream == null)
                {
                    return null;
                }
                assemblyData = ReadStream(assemblyStream);
            }

            using (var pdbStream = GetDebugStream(executingAssembly, prefix))
            {
                if (pdbStream != null)
                {
                    var pdbData = ReadStream(pdbStream);
                    return Assembly.Load(assemblyData, pdbData);
                }
            }

            return Assembly.Load(assemblyData);
        }
示例#7
0
        /// <summary>
        /// Applies the assembly resolver procedure.
        /// </summary>
        static CciAssemblyResolver()
        {
            _cachedAssemblies = new Dictionary <string, Assembly>();

            AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
            {
                if (_cachedAssemblies.ContainsKey(args.Name))
                {
                    return(_cachedAssemblies[args.Name]);
                }

                var name = new System.Reflection.AssemblyName(args.Name).Name;

                using (var stream = Assembly.GetExecutingAssembly()
                                    .GetManifestResourceStream(name))
                {
                    if (stream == null)
                    {
                        return(null);
                    }

                    var mStream = new MemoryStream();
                    stream.CopyTo(mStream);

                    _cachedAssemblies.Add(args.Name, Assembly.Load(mStream.GetBuffer()));
                }

                return(_cachedAssemblies[args.Name]);
            };
        }
示例#8
0
        internal static Type makeRecord(String name,Type basetype)
        {
            if(assembly == null)
            {
            AssemblyName assemblyName = new AssemblyName();
            assemblyName.Name = "RecordAssembly";
            assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName,AssemblyBuilderAccess.Run);
            module = assembly.DefineDynamicModule("RecordModule");
            }

            TypeBuilder tb = module.DefineType(name,TypeAttributes.Class|TypeAttributes.Public,basetype);
            Type[] paramTypes = Type.EmptyTypes;
            ConstructorBuilder cb = tb.DefineConstructor(MethodAttributes.Public,
                                                                    CallingConventions.Standard,
                                                                    paramTypes);
            ILGenerator constructorIL = cb.GetILGenerator();
            constructorIL.Emit(OpCodes.Ldarg_0);
            ConstructorInfo superConstructor = basetype.GetConstructor(Type.EmptyTypes);
            constructorIL.Emit(OpCodes.Call, superConstructor);
            constructorIL.Emit(OpCodes.Ret);

            Type t = tb.CreateType();
            //Import.AddType(t); //must do in lisp
            return t;
        }
示例#9
0
        static SqlCeFactory()
        {
            foreach (string supportedVersion in new string[] { "4.0.0.0" })
            {
                var name = new System.Reflection.AssemblyName("System.Data.SqlServerCe, Version=" + supportedVersion + ", Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL");

                try
                {
                    // This wil throw if SQL CE is not installed.  THe code should have called IsSQLCEInstalled before calling into this path.
                    assembly = Assembly.Load(name.FullName);
                    break;
                }
                catch
                {
                }
            }

            if (assembly != null)
            {
                CreateEngineLambdas();
                CreateConnectionLambda();
                CreateCommandLambda();
                CreateDataAdapterLambda();
            }
        }
示例#10
0
        public ExternTypeRef GetTypeRef(string asmb_name, string full_name, bool is_valuetype)
        {
            ExternAssembly ext_asmb = null;

            if (assembly_table == null && (asmb_name == "mscorlib" || asmb_name == "corlib"))
            {
                /* AddCorlib if mscorlib is being referenced but
                 * we haven't encountered a ".assembly 'name'" as yet. */
                Report.Warning(String.Format("Reference to undeclared extern assembly '{0}', adding.", asmb_name));
                AddCorlib();
            }
            if (assembly_table != null)
            {
                ext_asmb = assembly_table[asmb_name] as ExternAssembly;
            }

            if (ext_asmb == null)
            {
                System.Reflection.AssemblyName asmname = new System.Reflection.AssemblyName();
                asmname.Name = asmb_name;

                Report.Warning(String.Format("Reference to undeclared extern assembly '{0}', adding.", asmb_name));
                ext_asmb = AddAssembly(asmb_name, asmname, 0);
            }

            return(ext_asmb.GetTypeRef(full_name, is_valuetype));
        }
示例#11
0
 private void CreateCallee()
 {
     AssemblyName myAssemblyName = new AssemblyName();
     myAssemblyName.Name = "EnumAssembly";
     _myAssemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(myAssemblyName, AssemblyBuilderAccess.Run);
     _myModuleBuilder = TestLibrary.Utilities.GetModuleBuilder(_myAssemblyBuilder, "EnumModule.mod");
 }
示例#12
0
        public static void Load(Type T, string DllName)
        {
            AppDomain Cur = AppDomain.CurrentDomain;
            AssemblyName AsmName = new AssemblyName("RuntimePInvokeAsm");
            AssemblyBuilder AsmBuilder = Cur.DefineDynamicAssembly(AsmName, AssemblyBuilderAccess.RunAndSave);
            ModuleBuilder ModBuild = AsmBuilder.DefineDynamicModule(AsmName.Name);
            TypeBuilder TBuild = ModBuild.DefineType("RuntimePInvoke_" + T.Name, TypeAttributes.Public);
            MethodAttributes MAttr = MethodAttributes.Public | MethodAttributes.Static | MethodAttributes.PinvokeImpl;

            RuntimeDllImportAttribute Attr;
            FieldInfo[] Fields = T.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

            for (int i = 0; i < Fields.Length; i++)
                if (typeof(Delegate).IsAssignableFrom(Fields[i].FieldType) &&
                    (Attr = Fields[i].GetCustomAttribute<RuntimeDllImportAttribute>()) != null) {
                    MethodInfo MInf = Fields[i].FieldType.GetMethod("Invoke");

                    string EntryPoint = Attr.EntryPoint != null ? Attr.EntryPoint : Fields[i].Name;
                    MethodBuilder MB = TBuild.DefinePInvokeMethod(EntryPoint, DllName, MAttr, CallingConventions.Standard,
                    MInf.ReturnType, GetParamTypes(MInf), Attr.CallingConvention, Attr.CharSet);
                    if (Attr.PreserveSig)
                        MB.SetImplementationFlags(MB.GetMethodImplementationFlags() | MethodImplAttributes.PreserveSig);
                }

            Type RPInv = TBuild.CreateType();
            for (int i = 0; i < Fields.Length; i++)
                if (typeof(Delegate).IsAssignableFrom(Fields[i].FieldType) &&
                    (Attr = Fields[i].GetCustomAttribute<RuntimeDllImportAttribute>()) != null) {
                    string EntryPoint = Attr.EntryPoint != null ? Attr.EntryPoint : Fields[i].Name;
                    Fields[i].SetValue(null, Delegate.CreateDelegate(Fields[i].FieldType,
                        RPInv.GetMethod(EntryPoint, GetParamTypes(Fields[i].FieldType.GetMethod("Invoke"))), true));
                }
        }
示例#13
0
        /// <summary>
        /// Constructor for the AssemblyReferenceNode
        /// </summary>
        public AssemblyReferenceNode(ProjectNode root, string assemblyPath)
            : base(root)
        {
            // Validate the input parameters.
            if (null == root)
            {
                throw new ArgumentNullException("root");
            }
            if (string.IsNullOrEmpty(assemblyPath))
            {
                throw new ArgumentNullException("assemblyPath");
            }

            this.InitializeFileChangeEvents();

            // The assemblyPath variable can be an actual path on disk or a generic assembly name.
            if (File.Exists(assemblyPath))
            {
                // The assemblyPath parameter is an actual file on disk; try to load it.
                this.assemblyName = System.Reflection.AssemblyName.GetAssemblyName(assemblyPath);
                this.assemblyPath = assemblyPath;

                // We register with listeningto chnages onteh path here. The rest of teh cases will call into resolving the assembly and registration is done there.
                this.fileChangeListener.ObserveItem(this.assemblyPath);
            }
            else
            {
                // The file does not exist on disk. This can be because the file / path is not
                // correct or because this is not a path, but an assembly name.
                // Try to resolve the reference as an assembly name.
                this.CreateFromAssemblyName(new System.Reflection.AssemblyName(assemblyPath));
            }
        }
示例#14
0
		public void Register( string path )
		{
			try
			{
				AssemblyName assemblyName = new AssemblyName();
				assemblyName.Name = Path.GetFileNameWithoutExtension(path);
				assemblyName.CodeBase = path;
				Assembly assembly = Assembly.Load(assemblyName);
				NTrace.Debug( "Loaded " + Path.GetFileName(path) );

				foreach ( Type type in assembly.GetExportedTypes() )
				{
					if ( type.GetCustomAttributes(typeof(NUnitAddinAttribute), false).Length == 1 )
					{
						Addin addin = new Addin( type );
						addinRegistry.Register( addin );
						NTrace.Debug( "Registered addin: " + addin.Name );
					}
				}
			}
			catch( Exception ex )
			{
				// NOTE: Since the gui isn't loaded at this point, 
				// the trace output will only show up in Visual Studio
				NTrace.Error( "Failed to load" + path, ex  );
			}
		}
 static UnityExtension()
 {
     UnityExtension.Assembly        = System.Reflection.Assembly.GetExecutingAssembly();
     UnityExtension.AssemblyName    = UnityExtension.Assembly.GetName();
     UnityExtension.AssemblyVersion = new VersionNumber(UnityExtension.AssemblyName.Version.Major, UnityExtension.AssemblyName.Version.Minor, UnityExtension.AssemblyName.Version.Build);
     UnityExtension.AssemblyAuthors = ((AssemblyCompanyAttribute)Attribute.GetCustomAttribute(UnityExtension.Assembly, typeof(AssemblyCompanyAttribute), false)).Company;
 }
示例#16
0
        static SR.AssemblyName GetSymbolAssemblyName(SymbolKind kind)
        {
            if (kind == SymbolKind.PortablePdb)
            {
                throw new ArgumentException();
            }

            var suffix = GetSymbolNamespace(kind);

            var cecil_name = typeof(SymbolProvider).Assembly.GetName();

            var name = new SR.AssemblyName {
                Name    = cecil_name.Name + "." + suffix,
                Version = cecil_name.Version,
#if NET_CORE
                CultureName = cecil_name.CultureName,
#else
                CultureInfo = cecil_name.CultureInfo,
#endif
            };

            name.SetPublicKeyToken(cecil_name.GetPublicKeyToken());

            return(name);
        }
示例#17
0
        /// <summary>
        /// Does the actual job of resolving an assembly reference. We need a private method that does not violate
        /// calling virtual method from the constructor.
        /// </summary>
        private void ResolveAssemblyReference()
        {
            if (this.ProjectMgr == null || this.ProjectMgr.IsClosed)
            {
                return;
            }

            var group = this.ProjectMgr.CurrentConfig.GetItems(ProjectFileConstants.ReferencePath);

            foreach (var item in group)
            {
                string fullPath = CommonUtils.GetAbsoluteFilePath(this.ProjectMgr.ProjectHome, item.EvaluatedInclude);

                System.Reflection.AssemblyName name = System.Reflection.AssemblyName.GetAssemblyName(fullPath);

                // Try with full assembly name and then with weak assembly name.
                if (String.Equals(name.FullName, this.assemblyName.FullName, StringComparison.OrdinalIgnoreCase) || String.Equals(name.Name, this.assemblyName.Name, StringComparison.OrdinalIgnoreCase))
                {
                    if (!CommonUtils.IsSamePath(fullPath, this.assemblyPath))
                    {
                        // set the full path now.
                        this.assemblyPath = fullPath;

                        // We have a new item to listen too, since the assembly reference is resolved from a different place.
                        this.fileChangeListener.ObserveItem(this.assemblyPath);
                    }

                    this.resolvedAssemblyName = name;

                    // No hint path is needed since the assembly path will always be resolved.
                    return;
                }
            }
        }
示例#18
0
        protected override void ResolveReference()
        {
            if (this.ProjectMgr == null || this.ProjectMgr.IsClosed)
            {
                return;
            }

            MSBuild.BuildItemGroup group = this.ProjectMgr.BuildProject.GetEvaluatedItemsByName(ProjectFileConstants.ReferencePath);
            if (group != null)
            {
                IEnumerator enumerator = group.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    MSBuild.BuildItem item = (MSBuild.BuildItem)enumerator.Current;

                    string fullPath = this.GetFullPathFromPath(item.FinalItemSpec);

                    System.Reflection.AssemblyName name = System.Reflection.AssemblyName.GetAssemblyName(fullPath);

                    // Try with full assembly name and then with weak assembly name.
                    if (String.Compare(name.FullName, this.assemblyName.FullName, StringComparison.OrdinalIgnoreCase) == 0 || String.Compare(name.Name, this.assemblyName.Name, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        // set the full path now.
                        this.assemblyPath         = fullPath;
                        this.resolvedAssemblyName = name;

                        // No hint path is needed since the assembly path will always be resolved.
                        return;
                    }
                }
            }
        }
示例#19
0
 /// <summary>
 /// Constructor for the AssemblyReferenceNode
 /// </summary>
 public AssemblyReferenceNode(ProjectNode root, string assemblyPath)
     : base(root)
 {
     // Validate the input parameters.
     if (null == root)
     {
         throw new ArgumentNullException("root");
     }
     if (string.IsNullOrEmpty(assemblyPath))
     {
         throw new ArgumentNullException("assemblyPath");
     }
     // The assemblyPath variable can be an actual path on disk or a generic assembly name.
     if (File.Exists(assemblyPath))
     {
         // The assemblyPath parameter is an actual file on disk; try to load it.
         this.assemblyName = System.Reflection.AssemblyName.GetAssemblyName(assemblyPath);
         this.assemblyPath = assemblyPath;
     }
     else
     {
         // The file does not exist on disk. This can be because the file / path is not
         // correct or because this is not a path, but an assembly name.
         // Try to resolve the reference as an assembly name.
         CreateFromAssemblyName(new System.Reflection.AssemblyName(assemblyPath));
     }
 }
示例#20
0
文件: Util.cs 项目: txwizard/BitMath
		}   // ByteArrayToHexDigitString (2 of 2)
		/// <summary>
		/// List selected properties of any assembly on a console.
		/// </summary>
		/// <param name="pmyLib">
		/// Pass in a reference to the desired assembly, which may be the
		/// assembly that exports a specified type, the executing assembly, the
		/// calling assembly, the entry assembly, or any other assembly for
		/// which you can obtain a reference.
		/// </param>
		public static void ShowKeyAssemblyProperties ( System.Reflection.Assembly pmyLib )
		{
			System.Reflection.AssemblyName MyNameIs = System.Reflection.AssemblyName.GetAssemblyName ( pmyLib.Location );
			System.Diagnostics.FileVersionInfo myVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo ( pmyLib.Location );

			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_SELECTED_DLL_PROPS_BEGIN , Environment.NewLine );

			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_ASSEMBLYFILEBASENAME , System.IO.Path.GetFileNameWithoutExtension ( pmyLib.Location ) );
			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_VERSIONSTRING , myVersionInfo.FileVersion );
			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_CULTURE , MyNameIs.CultureInfo.DisplayName );
			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_PUBLICKEYTOKEN , Util.ByteArrayToHexDigitString ( MyNameIs.GetPublicKeyToken ( ) ) );

			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_RUNTIME_VERSION , pmyLib.ImageRuntimeVersion );
			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_ASSEMBLYGUIDSTRING , GetAssemblyGuidString ( pmyLib ) );

			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_PRODUCTNAME , myVersionInfo.ProductName );
			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_LEGALCOPYRIGHT , myVersionInfo.LegalCopyright );
			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_LEGALTRADEMARKS , myVersionInfo.LegalTrademarks );
			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_COMPANYNAME , myVersionInfo.CompanyName );

			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_DESCRIPTION , myVersionInfo.FileDescription );
			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_COMMENTS , myVersionInfo.Comments , Environment.NewLine );

			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_ASSEMBYDIRNAME , System.IO.Path.GetDirectoryName ( pmyLib.Location ) );
			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_ASSEMBLYFILENAME , System.IO.Path.GetFileName ( pmyLib.Location ) , Environment.NewLine );

			string strAssemblyFileFQFN = pmyLib.Location;
			System.IO.FileInfo fiLibraryFile = new System.IO.FileInfo ( strAssemblyFileFQFN );

			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_FILE_CREATION_DATE , fiLibraryFile.CreationTime , fiLibraryFile.CreationTimeUtc );
			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_FILE_MODIFIED_DATE , fiLibraryFile.LastWriteTime , fiLibraryFile.LastWriteTimeUtc );

			Console.WriteLine ( Properties.Resources.MSG_ASM_PROPS_SELECTED_DLL_PROPS_END , Environment.NewLine );
		}   // private static void ShowKeAssemblyProperties method
示例#21
0
 Assembly AssemblyResolve(object sender, ResolveEventArgs args)
 {
     // this should only be called to resolve OnlineVideos.dll -> return it regardless of the version, only the name "OnlineVideos"
     AssemblyName an = new AssemblyName(args.Name);
     var asm = (sender as AppDomain).GetAssemblies().FirstOrDefault(a => a.GetName().Name == an.Name);
     return asm;
 }
示例#22
0
        public void PosTest1()
        {
            AssemblyName myAsmName =
                new AssemblyName("TypeBuilderGetFieldTest");
            AssemblyBuilder myAssembly = AssemblyBuilder.DefineDynamicAssembly(
                myAsmName, AssemblyBuilderAccess.Run);
            ModuleBuilder myModule = TestLibrary.Utilities.GetModuleBuilder(myAssembly, "Module1");

            TypeBuilder myType = myModule.DefineType("Sample",
                TypeAttributes.Class | TypeAttributes.Public);

            string[] typeParamNames = { "T" };
            GenericTypeParameterBuilder[] typeParams =
                myType.DefineGenericParameters(typeParamNames);

            EventBuilder eb = myType.DefineEvent("TestEvent", EventAttributes.None, typeof(int));
            MethodBuilder addOnMethod = myType.DefineMethod("addOnMethod", MethodAttributes.Public);
            ILGenerator ilGen = addOnMethod.GetILGenerator();
            ilGen.Emit(OpCodes.Ret);
            MethodBuilder removeOnMethod = myType.DefineMethod("removeOnMethod", MethodAttributes.Public);
            ilGen = removeOnMethod.GetILGenerator();
            ilGen.Emit(OpCodes.Ret);
            eb.SetAddOnMethod(addOnMethod);
            eb.SetRemoveOnMethod(removeOnMethod);

            Type t = myType.CreateTypeInfo().AsType();

            EventInfo ei = t.GetEvent("TestEvent", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static);
            Assert.NotNull(ei);
        }
示例#23
0
		Assembly AssemblyResolve(object sender, ResolveEventArgs args) {
			var assembly = Get(args.Name);
			if (assembly != null)
				return assembly;

			var asmName = new AssemblyName(args.Name);
			foreach (var path in assemblySearchPaths) {
				foreach (var ext in assemblyExtensions) {
					try {
						var filename = Path.Combine(path, asmName.Name + ext);
						if (!new FileInfo(filename).Exists)
							continue;
						AddConfigFile(filename + ".config");
						return AddAssembly(Assembly.LoadFile(filename));
					}
					catch (IOException) {
					}
					catch (BadImageFormatException) {
					}
					catch (ArgumentException) {
					}
					catch (NotSupportedException) {
					}
					catch (UnauthorizedAccessException) {
					}
					catch (System.Security.SecurityException) {
					}
				}
			}

			return null;
		}
示例#24
0
            public void LoadWhenNeeded(string directory)
            {
                var cache = new Dictionary<string, Assembly>();
                AppDomain.CurrentDomain.AssemblyResolve +=
                    (a, b) =>
                    {
                        Assembly assembly;
                        if (cache.TryGetValue(b.Name, out assembly))
                        {
                            return assembly;
                        }

                        string shortName = new AssemblyName(b.Name).Name;
                        string path = Path.Combine(directory, shortName + ".dll");
                        if (File.Exists(path))
                        {
                            assembly = Assembly.LoadFile(path);
                        }
                        cache[b.Name] = assembly;
                        if (assembly != null)
                        {
                            cache[assembly.FullName] = assembly;
                        }
                        return assembly;
                    };
            }
 private TypeBuilder GetTypeBuilder(string typename)
 {
     AssemblyName assemblyname = new AssemblyName("assemblyname");
     AssemblyBuilder assemblybuilder = AssemblyBuilder.DefineDynamicAssembly(assemblyname, AssemblyBuilderAccess.Run);
     ModuleBuilder modulebuilder = TestLibrary.Utilities.GetModuleBuilder(assemblybuilder, ModuleName);
     return modulebuilder.DefineType(typename);
 }
示例#26
0
 static MethodInvoker(){
   MethodInvoker.invokerFor = new SimpleHashtable(64);
   AssemblyName name = new AssemblyName();
   name.Name = "JScript MethodInvoker Assembly";
   MethodInvoker.assembly = Thread.GetDomain().DefineDynamicAssembly(name, AssemblyBuilderAccess.Run);
   MethodInvoker.module = MethodInvoker.assembly.DefineDynamicModule("JScript MethodInvoker Module");
 }
 public void Should_return_false_if_item_matchs_by_pattern()
 {
     var ignore = new IgnoreFilterConfiguration();
     var name = new AssemblyName("Foo.Bar.Core");
     ignore.Patterns.Add(new ConfigurationItem(".*ar"));
     Assert.IsFalse(IgnoreFilter.From(ignore).Include(name));
 }
示例#28
0
        private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args)
        {
            Assembly cachedAsm;
            if (loadedAsmsCache.TryGetValue(args.Name, out cachedAsm))
                return cachedAsm;

            Assembly executingAssembly = Assembly.GetExecutingAssembly();
            AssemblyName assemblyName = new AssemblyName(args.Name);

            string path = assemblyName.Name + ".dll";
            if (assemblyName.CultureInfo != null && assemblyName.CultureInfo.Equals(CultureInfo.InvariantCulture) == false)
            {
                path = String.Format(@"{0}\{1}", assemblyName.CultureInfo, path);
            }

            using (Stream stream = executingAssembly.GetManifestResourceStream(path))
            {
                if (stream == null)
                    return null;

                byte[] assemblyRawBytes = new byte[stream.Length];
                stream.Read(assemblyRawBytes, 0, assemblyRawBytes.Length);
                var loadedAsm = Assembly.Load(assemblyRawBytes);
                loadedAsmsCache.Add(args.Name, loadedAsm);
                return loadedAsm;
            }
        }
        public void TestDefinePropertyWithGetAccessor()
        {
            AssemblyName an = new AssemblyName();
            an.Name = "Assembly1";
            AssemblyBuilder ab = AssemblyBuilder.DefineDynamicAssembly(an, AssemblyBuilderAccess.Run);

            ModuleBuilder mb = TestLibrary.Utilities.GetModuleBuilder(ab, "Module1");

            TypeBuilder tb = mb.DefineType("DerivedClass", TypeAttributes.Public | TypeAttributes.AutoClass | TypeAttributes.AnsiClass | TypeAttributes.BeforeFieldInit, typeof(TBBaseClass1));

            PropertyBuilder pb = tb.DefineProperty("Property", PropertyAttributes.None, CallingConventions.HasThis | CallingConventions.Standard, typeof(int), s_emptyTypes);

            MethodAttributes methodAttr = MethodAttributes.SpecialName | MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.ReuseSlot;
            CallingConventions conventions = CallingConventions.Standard | CallingConventions.HasThis;

            MethodBuilder getP = tb.DefineMethod("get_Property", methodAttr, conventions, typeof(int), s_emptyTypes);
            ILGenerator il = getP.GetILGenerator();
            il.Emit(OpCodes.Ldc_I4, 5);
            il.Emit(OpCodes.Ret);
            pb.SetGetMethod(getP);

            Type type = tb.CreateTypeInfo().AsType();
            PropertyInfo pi = type.GetProperty("Property"); //it shouldn't throw AmbiguousMatchException
            object obj = Activator.CreateInstance(type);
            int retValue = (int)type.GetProperty("Property").GetGetMethod().Invoke(obj, null);
            Assert.Equal(5, retValue);
        }
示例#30
0
 public MainWindow()
 {
     InitializeComponent();
     AppDomain d = AppDomain.CreateDomain("Domain");
     AssemblyName an = new AssemblyName("Assembly");
     d.ExecuteAssembly(an, null, null);
     ProcessesDataGrid.ItemsSource = Process.GetProcessesByName("devenv").Select(res => new { res.ProcessName, res.Id });
     //Возвращает нити одного процесса
     ThreadsDataGrid.ItemsSource = Process.GetProcessesByName("devenv")[0].Threads;
     //Возращае dll необходимые для работы процесса
     dllDataGrid.ItemsSource = Process.GetProcessesByName("devenv")[0].Modules;
     //Запуск приложения (пример)
     //Process.Start(new ProcessStartInfo() { FileName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", Arguments = @"https://en.wikipedia.org/wiki/CPU_time" });
     //Возвращает все сборки одного домена
     DomainInfoGrid.ItemsSource = AppDomain.CurrentDomain.GetAssemblies();
     //Creating of new domain
     //****************************************************************
     AppDomain NewDomain = AppDomain.CreateDomain("CalculationOfFactorial");
     NewDomain.AssemblyLoad += DomainAssemblyLoad;
     NewDomain.DomainUnload += DomainAssemblyUnLoad;
     int Number = 5;
     string[] args = new string[] { Number.ToString() };
     //Path to another exe file from current exe
     string PathToAssembly = NewDomain.BaseDirectory +
         "../../../../CalculationOfFactorial/CalculationOfFactorial/bin/Debug/CalculationOfFactorial.exe";
     //THis is the only way to dinamically add and remove libraries
     //Because we couldnt do that in THIS domain only in "NewDomain"
     NewDomain.Load(new AssemblyName("System.Data"));
     //We run here our another application
     NewDomain.ExecuteAssembly(PathToAssembly, args);
     DomainInfoGrid.ItemsSource = NewDomain.GetAssemblies();
     AppDomain.Unload(NewDomain);
     //******************************************************************
 }
示例#31
0
 private void AddAssemblyNameInfo(TreeNode _parent, AssemblyName _name)
 {
     AddInfo(_parent, "FullName", _name.FullName);
     AddInfo(_parent, "ProcessorArchitecture", _name.ProcessorArchitecture);
     AddInfo(_parent, "Version", _name.Version);
     AddInfo(_parent, "VersionCompatibility", _name.VersionCompatibility);
 }
示例#32
0
 public CreateShelfService(string serviceName, ShelfType shelfType, Type bootstrapperType, AssemblyName[] assemblyNames)
 {
     ServiceName = serviceName;
     ShelfType = shelfType;
     BootstrapperType = bootstrapperType;
     AssemblyNames = assemblyNames;
 }
示例#33
0
 private AssemblyBuilder CreateDynamicAssembly(string name, AssemblyBuilderAccess access)
 {
     AssemblyName myAsmName = new AssemblyName();
     myAsmName.Name = name;
     AssemblyBuilder myAsmBuilder = AssemblyBuilder.DefineDynamicAssembly(myAsmName, access);
     return myAsmBuilder;
 }
        public Form1()
        {
            AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
            {
                string resourceName = new AssemblyName(args.Name).Name + ".dll";
                string resource = Array.Find(this.GetType().Assembly.GetManifestResourceNames(), element => element.EndsWith(resourceName));

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

            InitializeComponent();

            if (ipAddrAuto && dnsAuto)
            {
                ipaddr_auto.Checked = true;
                ipaddr_manual.Checked = false;
                group_ipaddr.Enabled = false;
                dns_auto.Checked = true;
                dns_manual.Checked = false;
                group_dns.Enabled = false;
                con_wifi.Checked = true;
                con = "Wireless Network Connection";
            }
            if (!con_other.Checked)
            {
                con_other_custom.Enabled = false;
            }
        }
        public void TestOnOverridenInterfaceMethod()
        {
            string name = "Assembly1";
            AssemblyName asmname = new AssemblyName();
            asmname.Name = name;

            AssemblyBuilder asmbuild = AssemblyBuilder.DefineDynamicAssembly(asmname, AssemblyBuilderAccess.Run);
            ModuleBuilder modbuild = TestLibrary.Utilities.GetModuleBuilder(asmbuild, "Module1");
            TypeBuilder tpbuild = modbuild.DefineType("C1", TypeAttributes.Public);
            MethodBuilder methbuild = tpbuild.DefineMethod("M", MethodAttributes.Public | MethodAttributes.Virtual, typeof(int), null);
            ILGenerator ilgen = methbuild.GetILGenerator();
            ilgen.Emit(OpCodes.Ldc_I4, 2);
            ilgen.Emit(OpCodes.Ret);

            // C1 implements interface TBI1
            tpbuild.AddInterfaceImplementation(typeof(TBI1));

            MethodInfo md2 = typeof(TBI1).GetMethod("M");

            tpbuild.DefineMethodOverride(methbuild, md2);

            Type tp = tpbuild.CreateTypeInfo().AsType();

            MethodInfo mdInvoke = typeof(TBI1).GetMethod("M");
            int ret = (int)mdInvoke.Invoke(Activator.CreateInstance(tp), null);

            Assert.Equal(2, ret);
        }
        public void TestOnOverridenInterfaceMethodWithConflictingName()
        {
            string name = "Assembly1";
            AssemblyName asmname = new AssemblyName();
            asmname.Name = name;

            AssemblyBuilder asmbuild = AssemblyBuilder.DefineDynamicAssembly(asmname, AssemblyBuilderAccess.Run);
            ModuleBuilder modbuild = TestLibrary.Utilities.GetModuleBuilder(asmbuild, "Module1");
            TypeBuilder tpbuild = modbuild.DefineType("C1", TypeAttributes.Public, typeof(TBA1));
            MethodBuilder methbuild = tpbuild.DefineMethod("M2", MethodAttributes.Public | MethodAttributes.Virtual, typeof(int), null);
            ILGenerator ilgen = methbuild.GetILGenerator();
            ilgen.Emit(OpCodes.Ldc_I4, 2);
            ilgen.Emit(OpCodes.Ret);

            // C1 implements interface TBI1 and extends class TBA1
            tpbuild.AddInterfaceImplementation(typeof(TBI1));

            MethodInfo md2 = typeof(TBI1).GetMethod("M");

            tpbuild.DefineMethodOverride(methbuild, md2);

            Type tp = tpbuild.CreateTypeInfo().AsType();

            MethodInfo mdInvoke = typeof(TBI1).GetMethod("M");

            //         
            ConstructorInfo tpCtor = tp.GetConstructor(new Type[] { });
            object instOfTp = tpCtor.Invoke(new object[] { });
            int ret = (int)mdInvoke.Invoke(instOfTp, null);
            int retParent = (int)mdInvoke.Invoke(Activator.CreateInstance(typeof(TBA1)), null);

            Assert.True(ret == 2 && retParent == 1);
        }
        /// <summary>
        /// Create a Processor, indicating whether it is to be schema-aware.
        /// </summary>
        /// <param name="schemaAware">Set to true if the Processor is to be schema-aware.
        /// This requires the Saxon-SA product to be installed, with a valid license key.</param>
        /// <param name="loadLocally">Set to true if Saxon-SA is to be loaded from the application
        /// directory rather than from the Global Assembly Cache. This option should normally
        /// be set only when troubleshooting, for example when using a locally-patched version
        /// of the software.</param>

        public Processor(bool schemaAware, bool loadLocally) {
            if (schemaAware) {
                if (loadLocally) {
                    Assembly asm = Assembly.Load("saxon8sa");
                } else {
                    try {
                        int[] v = JVersion.getStructuredVersionNumber();
                        AssemblyName asn = new AssemblyName();
                        asn.Name = "saxon8sa";
                        asn.Version = new Version(v[0], v[1], v[2], v[3]);
                        //asn.Version = new Version(JVersion.getMajorVersion(), JVersion.getMinorVersion());
                        asn.SetPublicKeyToken(new byte[] { 0xe1, 0xfd, 0xd0, 0x02, 0xd5, 0x08, 0x3f, 0xe6 });
                        asn.CultureInfo = new CultureInfo("");
                        Assembly asm = Assembly.Load(asn);
                        // try to load the saxon8sa.dll assembly
                        //Assembly asm = Assembly.Load("saxon8sa, Ver=" + JVersion.getProductVersion() + ".0.1, " +
                        //    @"SN=e1fdd002d5083fe6, Loc=neutral");
                    } catch (Exception e) {
                        Console.WriteLine("Cannot load Saxon-SA software (assembly saxon8sa.dll version " +
                            JVersion.getProductVersion() + ".0.1)");
                        throw e;
                    }
                }
                config = JConfiguration.makeSchemaAwareConfiguration(null);
                schemaManager = new SchemaManager(config);
            } else {
                config = new JConfiguration();
            }
            config.setURIResolver(new DotNetURIResolver(new XmlUrlResolver()));
            config.setCollectionURIResolver(new DotNetCollectionURIResolver());
        }
		/// <summary>
		/// Adds an AssemblyResolve handler to redirect all failed assembly load attempts
		/// </summary>
		/// <remarks>
		/// http://blog.slaks.net/2013-12-25/redirecting-assembly-loads-at-runtime/
		/// </remarks>
		/// <param name="shortName">The short name.</param>
		/// <param name="targetVersion">The target version.</param>
		/// <param name="publicKeyToken">The public key token.</param>
		public static void RedirectAssembly(string shortName, Version targetVersion, string publicKeyToken)
		{
			ResolveEventHandler handler = null;

			handler = (sender, args) =>
			{
				// Use latest strong name & version when trying to load SDK assemblies
				var requestedAssembly = new AssemblyName(args.Name);
				if (requestedAssembly.Name != shortName)
				{
					return null;
				}

				requestedAssembly.Version = targetVersion;
				requestedAssembly.SetPublicKeyToken(new AssemblyName("x, PublicKeyToken=" + publicKeyToken).GetPublicKeyToken());
				requestedAssembly.CultureInfo = CultureInfo.InvariantCulture;

				AppDomain.CurrentDomain.AssemblyResolve -= handler;

				var assembly = Assembly.Load(requestedAssembly);

				return assembly;
			};

			AppDomain.CurrentDomain.AssemblyResolve += handler;
		}
示例#39
0
         /// <summary>
        /// Initializes a new instance of the <see cref="SetAccessorFactory"/> class.
        /// </summary>
        /// <param name="allowCodeGeneration">if set to <c>true</c> [allow code generation].</param>
        public SetAccessorFactory(bool allowCodeGeneration)
		{
            if (allowCodeGeneration)
            {
                // Detect runtime environment and create the appropriate factory
                if (Environment.Version.Major >= 2)
                {
                    _createPropertySetAccessor = new CreatePropertySetAccessor(CreateDynamicPropertySetAccessor);
                    _createFieldSetAccessor = new CreateFieldSetAccessor(CreateDynamicFieldSetAccessor);
                }
                else
                {
                    AssemblyName assemblyName = new AssemblyName();
                    assemblyName.Name = "iBATIS.FastSetAccessor" + HashCodeProvider.GetIdentityHashCode(this);

                    // Create a new assembly with one module
                    _assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
                    _moduleBuilder = _assemblyBuilder.DefineDynamicModule(assemblyName.Name + ".dll");

                    _createPropertySetAccessor = new CreatePropertySetAccessor(CreatePropertyAccessor);
                    _createFieldSetAccessor = new CreateFieldSetAccessor(CreateFieldAccessor);
                }
            }
            else
            {
                _createPropertySetAccessor = new CreatePropertySetAccessor(CreateReflectionPropertySetAccessor);
                _createFieldSetAccessor = new CreateFieldSetAccessor(CreateReflectionFieldSetAccessor);
            }
        }
示例#40
0
 public DataTypeBuilder(string name)
 {
     var assemblyName = new AssemblyName {Name = name};
     _moduleBuilder =
         AppDomain.CurrentDomain.DefineDynamicAssembly(
             assemblyName, AssemblyBuilderAccess.Run).DefineDynamicModule(name);
 }
示例#41
0
 static PropertyAccessor()
 {
     AssemblyName asmName = new AssemblyName();
     asmName.Name = "$Assembly.Hprose.IO.PropertyAccessor";
     asmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(asmName, AssemblyBuilderAccess.Run);
     modBuilder = asmBuilder.DefineDynamicModule("$Module.PropertyAccessor");
 }
示例#42
0
		public static void Main()
		{
			var an = new AssemblyName()
			{
				Version = new Version(1, 0, 0, 0),
				Name = "QuoteOfTheDay"
			};

			var ab = AppDomain.CurrentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.Save);
			var modBuilder = ab.DefineDynamicModule("QuoteOfTheDay", "QuoteOftheDay.dll");
			var tb = modBuilder.DefineType("QuoteOfTheDay.QuoteOfTheDay", TypeAttributes.Class | TypeAttributes.Public);
			var fields = new FieldSet(tb);
			fields.DefinePrivateField<ArrayList>("_quotes");
			fields.DefinePrivateField<Random>("_random");
			
			var ilgen = Generate_Constructor(tb, fields);

			//////////////////////////////////////////////////

			Generate_GetRandomQuote(ilgen, tb, fields);

			tb.CreateType();

			ab.Save("QuoteOfTheDay.dll");
		}
        internal SecureFactory(Manager host,
                               int flags,
                               int zone,
                               string URL,
                               byte[] uniqueId,
                               byte[] fileHash,
                               string assemblyName,
                               string typeName)
        {
            _host  = host;
            _flags = flags;
            _zone  = zone;
            _URL   = URL;

            if (uniqueId != null && uniqueId.Length > 0)
            {
                _uniqueId = new byte[uniqueId.Length];
                Array.Copy(uniqueId, _uniqueId, uniqueId.Length);
            }

            if (fileHash != null && fileHash.Length > 0)
            {
                _fileHash = new byte[fileHash.Length];
                Array.Copy(fileHash, _fileHash, fileHash.Length);
            }

            _assemblyName          = new AssemblyName();
            _assemblyName.CodeBase = URL;
            _typeName = typeName;

            Manager.Log(this, true, "Create SecureFactory() with security information", "");
        }
示例#44
0
        public void TestGetField()
        {
            AssemblyName myAsmName =
                new AssemblyName("TypeBuilderGetFieldTest");
            AssemblyBuilder myAssembly = AssemblyBuilder.DefineDynamicAssembly(
                 myAsmName, AssemblyBuilderAccess.Run);
            ModuleBuilder myModule = TestLibrary.Utilities.GetModuleBuilder(myAssembly, "Module1");

            TypeBuilder myType = myModule.DefineType("Sample",
                TypeAttributes.Class | TypeAttributes.Public);

            string[] typeParamNames = { "T" };
            GenericTypeParameterBuilder[] typeParams =
                myType.DefineGenericParameters(typeParamNames);

            FieldBuilder myField = myType.DefineField("Field",
                typeParams[0].AsType(),
                FieldAttributes.Public);

            Type SampleOfInt =
                myType.MakeGenericType(typeof(int));
            FieldInfo fi = TypeBuilder.GetField(SampleOfInt,
                myField);

            Assert.Equal("Field", fi.Name);
        }
示例#45
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            System.Reflection.AssemblyName an = Assembly.GetExecutingAssembly().GetName();
            string sVer  = an.Version.Major.ToString() + "." + an.Version.Minor.ToString();
            string sVer2 = an.Version.Major.ToString() + "." + an.Version.Minor.ToString() + "." + an.Version.Revision.ToString();

            MessageBox.Show("Version: " + sVer2 + "\n\nThis utility is freeware and comes as is, with no support.", "KML2GPX " + sVer + "  By Derek Rosen");
        }
示例#46
0
        public static Version GetVersion()
        {
            System.Reflection.Assembly     assembly     = System.Reflection.Assembly.GetExecutingAssembly();
            System.Reflection.AssemblyName assemblyName = assembly.GetName();
            Version version = assemblyName.Version;

            return(version);
        }
 static RustExtension()
 {
     RustExtension.Assembly        = System.Reflection.Assembly.GetExecutingAssembly();
     RustExtension.AssemblyName    = RustExtension.Assembly.GetName();
     RustExtension.AssemblyVersion = new VersionNumber(RustExtension.AssemblyName.Version.Major, RustExtension.AssemblyName.Version.Minor, RustExtension.AssemblyName.Version.Build);
     RustExtension.AssemblyAuthors = ((AssemblyCompanyAttribute)Attribute.GetCustomAttribute(RustExtension.Assembly, typeof(AssemblyCompanyAttribute), false)).Company;
     RustExtension.Filter          = new String[] { "alphamapResolution is clamped to the range of", "AngryAnt Behave version", "Floating point textures aren't supported on this device", "HDR RenderTexture format is not supported on this platform.", "Image Effects are not supported on this platform.", "Missing projectileID", "Motion vectors not supported on a platform that does not support", "The image effect Main Camera", "The image effect effect -", "Unable to find shaders", "Unsupported encoding: 'utf8'", "Warning, null renderer for ScaleRenderer!", "[AmplifyColor]", "[AmplifyOcclusion]", "[CoverageQueries] Disabled due to unsupported", "[CustomProbe]", "[Manifest] URI IS", "[SpawnHandler] populationCounts" };
 }
示例#48
0
        /// <summary>
        /// Construtor padrão.
        /// </summary>
        private ClassFactory()
        {
            var name = new System.Reflection.AssemblyName("DynamicClasses");

            _module  = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.Run).DefineDynamicModule("Module");
            _classes = new Dictionary <Signature, Type>();
            _rwLock  = new ReaderWriterLock();
        }
示例#49
0
 public AppInfo()
 {
     InitializeComponent();
     System.Reflection.Assembly     assembly = Assembly.GetExecutingAssembly();
     System.Reflection.AssemblyName asmName  = assembly.GetName();
     System.Version versions = asmName.Version;
     version.Text = "Version V." + versions.ToString();
 }
示例#50
0
 public Data()
 {
     assemblyName = new SR.AssemblyName("DynamicAssembly" + v++);
     ab           = AppDomain.CurrentDomain.DefineDynamicAssembly(
         assemblyName,
         AssemblyBuilderAccess.RunAndSave);
     mb = ab.DefineDynamicModule(assemblyName.Name, assemblyName.Name + ".dll");
 }
示例#51
0
        private void saveILAsDLLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (DynarecConfig.FunctionCallWithStaticReferences)
            {
                MessageBox.Show("_DynarecConfig.FunctionCallWithStaticReferences enabled. It will break exporting.");
            }

            var nameOfAssembly = "OutputAssembly";
            var nameOfModule   = "OutputModule";
            var nameOfDLL      = "cspspemu_temp_output.dll";
            var nameOfType     = "OutputType";

            var SaveFileDialog = new SaveFileDialog();

            SaveFileDialog.FileName     = nameOfDLL;
            SaveFileDialog.DefaultExt   = ".dll";
            SaveFileDialog.AddExtension = true;
            var Result = SaveFileDialog.ShowDialog();

            if (Result != System.Windows.Forms.DialogResult.Cancel)
            {
                var AssemblyName = new System.Reflection.AssemblyName {
                    Name = nameOfAssembly
                };
                var AssemblyBuilder =
                    Thread.GetDomain().DefineDynamicAssembly(AssemblyName, AssemblyBuilderAccess.Save);
                var ModuleBuilder = AssemblyBuilder.DefineDynamicModule(nameOfModule, nameOfDLL);
                var TypeBuilder   = ModuleBuilder.DefineType(nameOfType, TypeAttributes.Public | TypeAttributes.Class);

                //FieldBuilder targetWrapedObjectField = typeBuilder.DefineField("_" + targetWrapType.FullName.Replace(".", ""), targetWrapType, System.Reflection.FieldAttributes.Private);
                //MethodAttributes constructorAttributes = System.Reflection.MethodAttributes.Public;
                //
                //Type objType = Type.GetType("System.Object");
                //ConstructorInfo objCtor = objType.GetConstructor(new Type[0]);
                //ConstructorBuilder constructorBuilder = typeBuilder.DefineConstructor(constructorAttributes, System.Reflection.CallingConventions.Standard, new Type[] { targetWrapType });
                //System.Reflection.Emit.ILGenerator ilConstructor = constructorBuilder.GetILGenerator();

                foreach (var PC in CpuProcessor.MethodCache.PCs.OrderBy(Item => Item))
                {
                    var Entry = CpuProcessor.MethodCache.GetForPc(PC);
                    if (Entry.AstTree != null)
                    {
                        var MethodBuilder = TypeBuilder.DefineMethod("Method_" + Entry.Name,
                                                                     MethodAttributes.Public | MethodAttributes.Static, typeof(void),
                                                                     new[] { typeof(CpuThreadState) });
                        Entry.AstTree.GenerateIl(MethodBuilder, MethodBuilder.GetILGenerator());
                        //MethodBuilder.CreateDelegate(typeof(Action<CpuThreadState>));
                    }

                    //break;
                }

                TypeBuilder.CreateType();

                AssemblyBuilder.Save(nameOfDLL);
                File.Copy(nameOfDLL, SaveFileDialog.FileName, true);
            }
        }
 internal SecureFactory(Manager host,
                        string assemblyName,
                        string typeName)
 {
     _host              = host;
     _assemblyName      = new AssemblyName();
     _assemblyName.Name = assemblyName;
     _typeName          = typeName;
 }
示例#53
0
 private bool MatchAssemblyName(string file, AssemblyNameReference name)
 {
     try {
         System.Reflection.AssemblyName an = System.Reflection.AssemblyName.GetAssemblyName(file);
         return(an.FullName == name.FullName);
     }
     catch {
         return(true);
     }
 }
 internal static bool IsAssemblyNameAssignmentSafe(string originalAssemblyName, string newAssemblyName)
 {
     if (originalAssemblyName == newAssemblyName)
     {
         return(true);
     }
     System.Reflection.AssemblyName name  = new System.Reflection.AssemblyName(originalAssemblyName);
     System.Reflection.AssemblyName name2 = new System.Reflection.AssemblyName(newAssemblyName);
     return((!string.Equals(name2.Name, "mscorlib", StringComparison.OrdinalIgnoreCase) && !string.Equals(name2.Name, "mscorlib.dll", StringComparison.OrdinalIgnoreCase)) && Compare(name.GetPublicKeyToken(), name2.GetPublicKeyToken()));
 }
示例#55
0
        /// <summary>
        /// Look through already imported assemblies for
        /// a match.
        /// </summary>
        private SR.Assembly DomainAssemblyResolve(object sender, ResolveEventArgs args)
        {
            SR.AssemblyName assemblyName = new SR.AssemblyName(args.Name);

            if (Assemblies.ContainsKey(assemblyName.Name))
            {
                return(Assemblies[assemblyName.Name].Item1);
            }
            return(null);
        }
示例#56
0
		//See: https://stackoverflow.com/a/33277079
		//This resolver method will ignore version, cultures and keys to make loading more reasonable.
		private static System.Reflection.Assembly GGDBFAssemblyResolver(System.Reflection.AssemblyName assemblyName)
		{
			assemblyName.Version = null;
			assemblyName.SetPublicKey(null);
			assemblyName.SetPublicKeyToken(null);
			assemblyName.CultureInfo = null;
			assemblyName.CultureName = null;

			return System.Reflection.Assembly.Load(assemblyName);
		}
示例#57
0
        /// Return the path to the file which the given assembly was loaded.
        /// If that assembly has not been loaded, this returns null.
        public string GetPathOfAssembly(System.Reflection.AssemblyName name)
        {
            Assembly a = GetAssembly(name, false);

            if (a != null)
            {
                return(a.Location);
            }
            return(null);
        }
示例#58
0
 private static Assembly AssemblyResolver(System.Reflection.AssemblyName assemblyName)
 {
     if (assemblyName.Name == "System.Collections")
     {
         // Horrible hack!
         // If loading something on Framework, doesn't currently have anything beyond v4.0,
         // but stuff saved in Standard or Core could be later...
         assemblyName.Version = new Version(4, 0, 0, 0);
     }
     return(Assembly.Load(assemblyName));
 }
示例#59
0
        private void LlamarFormulario()
        {
            try
            {
                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   = this;
                        Formulario.Tag         = InfoMenu;
                        Formulario.WindowState = FormWindowState.Maximized;
                        Formulario.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name;
                NameMetodo = NameMetodo + " - " + ex.ToString();
                MessageBox.Show(NameMetodo + " " + param.Get_Mensaje_sys(enum_Mensajes_sys.Error_comunicarse_con_sistemas)
                                , param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString());
            }
        }
示例#60
0
        private Hash ComputeHash()
        {
            var hash = new Hash();

            // Shell settings physical location
            //   The nhibernate configuration stores the physical path to the SqlCe database
            //   so we need to include the physical location as part of the hash key, so that
            //   xcopy migrations work as expected.
            var pathName = GetPathName(_shellSettings.Name);

            hash.AddString(_appDataFolder.MapPath(pathName).ToLowerInvariant());

            // Orchard version, to rebuild the mappings for each new version
            var orchardVersion = new System.Reflection.AssemblyName(typeof(Orchard.ContentManagement.ContentItem).Assembly.FullName).Version.ToString();

            hash.AddString(orchardVersion);

            // Shell settings data
            hash.AddString(_shellSettings.DataProvider);
            hash.AddString(_shellSettings.DataTablePrefix);
            hash.AddString(_shellSettings.DataConnectionString);
            hash.AddString(_shellSettings.Name);

            // Assembly names, record names and property names
            foreach (var tableName in _shellBlueprint.Records.Select(x => x.TableName))
            {
                hash.AddString(tableName);
            }

            foreach (var recordType in _shellBlueprint.Records.Select(x => x.Type))
            {
                hash.AddTypeReference(recordType);

                if (recordType.BaseType != null)
                {
                    hash.AddTypeReference(recordType.BaseType);
                }

                foreach (var property in recordType.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance))
                {
                    hash.AddString(property.Name);
                    hash.AddTypeReference(property.PropertyType);

                    foreach (var attr in property.GetCustomAttributesData())
                    {
                        hash.AddTypeReference(attr.Constructor.DeclaringType);
                    }
                }
            }

            _configurers.Invoke(c => c.ComputingHash(hash), Logger);

            return(hash);
        }