Exemple #1
0
        private AssemblyGen()
        {
            var name = new AssemblyName("Snippets");

            // mark the assembly transparent so that it works in partial trust:
            var attributes = new[] {
                new CustomAttributeBuilder(typeof(SecurityTransparentAttribute).GetConstructor(Type.EmptyTypes), ArrayReservoir <object> .EmptyArray)
            };

            _assemblyBuilder = AssemblyBuilderEx.DefineDynamicAssembly(name, AssemblyBuilderAccess.Run, attributes);
            _moduleBuilder   = _assemblyBuilder.DefineDynamicModule(name.Name);
        }
Exemple #2
0
        private AssemblyGen()
        {
            var name = new AssemblyName("Snippets");

            // mark the assembly transparent so that it works in partial trust:
            var constructor = typeof(SecurityTransparentAttribute).GetConstructor(Type.EmptyTypes);

            if (constructor == null)
            {
                throw new ApplicationException("Unable to create SecurityTransparentAttribute");
            }
            var attributes = new[] {
                new CustomAttributeBuilder(constructor, ArrayReservoir <object> .EmptyArray)
            };

            var assemblyBuilder = AssemblyBuilderEx.DefineDynamicAssembly(name, AssemblyBuilderAccess.Run, attributes);

            _moduleBuilder = assemblyBuilder.DefineDynamicModule(name.Name);
        }