Пример #1
0
        private ArrayList ImportCom(ComReferenceProjectItem t)
        {
            ArrayList refrences = new ArrayList();

            refrences.Add(t as ReferenceProjectItem);
            BeginInvoke(new MethodInvoker(delegate { tsMessage.Text = "Compiling COM component '" + t.Include + "' ..."; }));
            Converter.TlbImp importer = new Converter.TlbImp(refrences);
            importer.ReportEvent += new EventHandler <Converter.ReportEventEventArgs>(importer_ReportEvent);
            importer.ResolveRef  += new EventHandler <Converter.ResolveRefEventArgs>(importer_ResolveRef);
            string outputFolder    = Path.GetDirectoryName(m_AIMSProject.OutputAssemblyFullPath);
            string interopFileName = Path.Combine(outputFolder, String.Concat("Interop.", t.Include, ".dll"));
            string asmPath         = interopFileName;

            importer.Import(asmPath, t.FilePath, t.Name);
            return(refrences);
        }
Пример #2
0
        public Assembly Import(string InteropFileName, string path, string name, TlbImp parent)
        {
            ITypeLib typeLib;

            AsmPath = Path.GetDirectoryName(InteropFileName);
            LoadTypeLibEx(path, RegKind.RegKind_None, out typeLib);

            if (typeLib == null)
            {
                return(null);
            }
            TypeLibConverter       converter    = new TypeLibConverter();
            ConversionEventHandler eventHandler = new ConversionEventHandler(parent == null?this:parent);
            AssemblyBuilder        asm          =
                converter.ConvertTypeLibToAssembly(typeLib, Path.GetFileName(InteropFileName), TypeLibImporterFlags.None, eventHandler, null, null, name, null);
            string outputFolder = Path.GetDirectoryName(InteropFileName);
            string interopFName = Path.Combine(outputFolder, String.Concat("Interop.", name, ".dll"));

            asm.Save(Path.GetFileName(interopFName));
            Marshal.ReleaseComObject(typeLib);
            return(asm as Assembly);
        }
Пример #3
0
 public ConversionEventHandler(TlbImp parent)
 {
     Parent = parent;
 }