0

I am trying to create interop dlls.

Two ways to do, 1. Using C# program, 2. Coomand line
1. C# program:

        public class ConversionEventHandler : ITypeLibImporterNotifySink
        {
            public void ReportEvent(ImporterEventKind eventKind, int eventCode, string eventMsg)
            {
                //   Console.WriteLine("{0}", eventMsg);
            }

            public Assembly ResolveRef(object typeLib)
            {
                return null
            }
        }

        Object typeLib;
        LoadTypeLibEx(@"C:\Windows\SysWOW64\activeds.tlb", RegKind.RegKind_None, out typeLib);
        Version v = new Version(1, 0, 0, 0);
        TypeLibConverter tlbConv = new TypeLibConverter();
        AssemblyBuilder asm = tlbConv.ConvertTypeLibToAssembly(typeLib, "outDll", 0,new ConversionEventHandler(), null, null, rootNamespace, v);
        asm.Save("outDll");

Here issue comes with its unknown to what should provide inResolveRef method.

  1. Command line: With Developer Coomand Prompt for VS:

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin>TlbImp.exe C:\Windows\SysWOW64\activeds.tlb out:test.dll

This is working, but I need to run above command using C#.

Can anyone please let me know how I can do this?

Thanks in advance

sowjanya attaluri
  • 903
  • 2
  • 9
  • 27
DSP
  • 179
  • 4
  • 1
    Why do you think you need to run tlbimp at runtime? What are you going to do with the results? – CodeCaster Jun 29 '16 at 08:07
  • You could use Marshal.GetTypeLibName(). That will return "stdole2.tlb" in this specific case, that one is present in the same directory. More generally, you'd consider using ITypeLib.GetLibAttr() to get the TLIBATTR.guid and look that up in the registry. In this specific case in HKLM\Software\Wow6432Node\Typelib. Or you [use this](http://clrinterop.codeplex.com/releases/view/17579). – Hans Passant Jun 29 '16 at 12:19

0 Answers0