Re: IDL to C#?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Mattias Sjögren (mattias.dont.want.spam_at_mvps.org)
Date: 07/16/04


Date: Fri, 16 Jul 2004 11:20:25 +0200


>Is there any tool that can convert and Interface definitions (especially
>oleidl.idl) to C# interface definitions?
>does MIDL.exe do that? i could just get c++ header files.

MIDL and TlbImp is the way to go. But for MIDL to produce a typelib I
belive you need a library {} block in the IDL file, which is missing
in Oleidl.idl.

But for non automation interfaces like those in Oleidl.idl, the IA
produced by Tlbimp isn't always perfect, and you may have to modify it
to make it really usable. So it's often easier to write your own COM
interface declarations directly in C# instead. You can find examples
of that in the .NET SDK directory
Samples\Technologies\Interop\Applications\ShellCmd

Mattias

-- 
Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Relevant Pages

  • Re: MarshalAs for Properties?
    ... generate by TLBIMP. ... MarshalAs attribute for the value parameter of the C# set accessor. ... definition of your interface. ... > When I'm doing Method mapping I can pass a parameter and ...
    (microsoft.public.dotnet.framework.interop)
  • Re: IDL to C#?
    ... but many attributes used in the oleidl.idl cant be parsed be ... > MIDL and TlbImp is the way to go. ... > interface declarations directly in C# instead. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Interop Assembly .nettiger machen?
    ... Dann wird TlbImp die Methode als Interface marshallen. ... kannst weil z.B. das COM-Objekt bereits veröffentlicht ist, lass den TlbImp-Schritt aus und deklariere den ComImport manuell: ... instance void MethodppInterface) ...
    (microsoft.public.de.german.entwickler.dotnet.framework)
  • Re: Interop Assembly .nettiger machen?
    ... > Die Typelibrary des COM-Objects ist nicht ganz so freudlich. ... > Hast du die Quellen? ... Dann wird TlbImp die Methode als Interface ...
    (microsoft.public.de.german.entwickler.dotnet.framework)
  • Re: Parametername ActiveX Control herausfinden
    ... public static extern ITypeLib LoadTypeLib([In, ... Typelib zu holen. ... genannte ITypeLib Interface) einige Interfaces, Enums, ... ...
    (microsoft.public.de.german.entwickler.dotnet.framework)