예제 #1
0
 protected virtual void OnResolveRef(ResolveRefEventArgs e)
 {
     if (ResolveRef != null)
     {
         ResolveRef(this, e);
     }
 }
예제 #2
0
        public Assembly ResolveRef(object typeLib)
        {
            ITypeLib tLib = typeLib as ITypeLib;
            string   tLibname;
            string   outputFolder = "";
            string   interopFileName;
            string   asmPath;

            try
            {
                tLibname = Marshal.GetTypeLibName(tLib);
                IntPtr ppTlibAttri = IntPtr.Zero;
                tLib.GetLibAttr(out ppTlibAttri);
                System.Runtime.InteropServices.ComTypes.TYPELIBATTR tLibAttri = (System.Runtime.InteropServices.ComTypes.TYPELIBATTR)Marshal.PtrToStructure(ppTlibAttri, typeof(System.Runtime.InteropServices.ComTypes.TYPELIBATTR));
                string           guid        = tLibAttri.guid.ToString();
                RegistryKey      typeLibsKey = Registry.ClassesRoot.OpenSubKey("TypeLib\\{" + guid + "}");
                TypeLibrary      typeLibrary = TypeLibrary.Create(typeLibsKey);
                Converter.TlbImp importer    = new Converter.TlbImp(Parent.References);
                outputFolder    = Path.GetDirectoryName(this.Parent.AsmPath);
                interopFileName = Path.Combine(outputFolder, String.Concat("Interop.", typeLibrary.Name, ".dll"));

                asmPath = interopFileName;
                //asm.Save(Path.GetFileName(asmPath));
                //Call ResolveRefEventArgs to notify extra assembly imported as depenedencies
                ResolveRefEventArgs t = new ResolveRefEventArgs("Reference Interop '" + Path.GetFileName(asmPath) + "' created succesfully.");
                Parent.InvokeResolveRef(t);
                Parent.References.Add(new ComReferenceProjectItem(ScriptControl.GetProject(), typeLibrary));
                return(importer.Import(interopFileName, typeLibrary.Path, typeLibrary.Name, this.Parent));
            }
            catch (Exception Ex)
            {
                ResolveRefEventArgs t = new ResolveRefEventArgs(Ex.Message);
                Parent.InvokeResolveRef(t);
                return(null);
            }
            finally
            {
                Marshal.ReleaseComObject(tLib);
            }
        }
예제 #3
0
 void importer_ResolveRef(object sender, Converter.ResolveRefEventArgs e)
 {
     BeginInvoke(new MethodInvoker(delegate { tsMessage.Text = e.Message; }));
     BeginInvoke(new MethodInvoker(delegate { _winOutput.AppendLine(e.Message); }));
 }
예제 #4
0
 public void InvokeResolveRef(ResolveRefEventArgs e)
 {
     OnResolveRef(e);
 }