예제 #1
0
        private static void SetImportedFromTypeLibAttrOnAssembly(AssemblyBuilder asmBldr, object typeLib)
        {
            CustomAttributeBuilder customBuilder = new CustomAttributeBuilder(typeof(ImportedFromTypeLibAttribute).GetConstructor(new Type[1] {
                typeof(string)
            }), new object[1] {
                (object)Marshal.GetTypeLibName((ITypeLib)typeLib)
            });

            asmBldr.SetCustomAttribute(customBuilder);
        }
        private static void SetImportedFromTypeLibAttrOnAssembly(AssemblyBuilder asmBldr, object typeLib)
        {
            Type[]          types       = new Type[] { typeof(string) };
            ConstructorInfo constructor = typeof(ImportedFromTypeLibAttribute).GetConstructor(types);
            string          typeLibName = Marshal.GetTypeLibName((ITypeLib)typeLib);

            object[] constructorArgs             = new object[] { typeLibName };
            CustomAttributeBuilder customBuilder = new CustomAttributeBuilder(constructor, constructorArgs);

            asmBldr.SetCustomAttribute(customBuilder);
        }
예제 #3
0
 public Assembly ResolveRef(object TypeLib)
 {
     try
     {
         ITypeLibConverter converter = new TypeLibConverter();
         return(converter.ConvertTypeLibToAssembly(TypeLib, Marshal.GetTypeLibName((ITypeLib)TypeLib) + ".dll", TypeLibImporterFlags.None, new ImporterCallback(), null, null, null, null));
     }
     catch (Exception)
     {
         return(null);
     }
 }
예제 #4
0
        [System.Security.SecurityCritical]  // auto-generated
        private static void SetImportedFromTypeLibAttrOnAssembly(AssemblyBuilder asmBldr, Object typeLib)
        {
            // Retrieve the ImportedFromTypeLibAttribute constructor.
            Type [] aConsParams = new Type[1] {
                typeof(String)
            };
            ConstructorInfo ImpFromComAttrCons = typeof(ImportedFromTypeLibAttribute).GetConstructor(aConsParams);

            // Retrieve the name of the typelib.
            String strTypeLibName = Marshal.GetTypeLibName((ITypeLib)typeLib);

            // Create an instance of the custom attribute builder.
            Object[] aArgs = new Object[1] {
                strTypeLibName
            };
            CustomAttributeBuilder ImpFromComCABuilder = new CustomAttributeBuilder(ImpFromComAttrCons, aArgs);

            // Set the ImportedFromTypeLibAttribute on the assembly builder.
            asmBldr.SetCustomAttribute(ImpFromComCABuilder);
        }
예제 #5
0
 public Assembly ResolveRef(object TypeLib)
 {
     try
     {
         return((Assembly) new TypeLibConverter().ConvertTypeLibToAssembly(TypeLib, Marshal.GetTypeLibName((ITypeLib)TypeLib) + ".dll", TypeLibImporterFlags.None, (ITypeLibImporterNotifySink) new ImporterCallback(), (byte[])null, (StrongNameKeyPair)null, (string)null, (Version)null));
     }
     catch (Exception ex)
     {
         return((Assembly)null);
     }
 }