COM -> CSharp Interface generator

R

Rick Strahl [MVP]

Does anybody know of a tool of some sort that can generate a C# interface
from a COM interface? I need to pull a ton of interfaces out of an existing
application and it sure would be lot nicer to get at least a rough headstart
with these interfaces.

Is there such thing before I sit down and write somehting like this on my
own?


+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
 
J

Joe Mayo [C# MVP]

Rick Strahl said:
Does anybody know of a tool of some sort that can generate a C# interface
from a COM interface? I need to pull a ton of interfaces out of an existing
application and it sure would be lot nicer to get at least a rough headstart
with these interfaces.

Is there such thing before I sit down and write somehting like this on my
own?


Hi Rick,

I haven't seen anything that does that. However, here's an idea that I'll
throw out there to see if it will save you some work. What if you used
reflection on the tlbimp.exe generated proxy to pull out the interfaces and
generate code from there.

Joe
 
P

PEACEMAKER

doesn't visual studio 7.1 have this built in? where it imports an com
interface for you to use in c#?
 
R

Rick Strahl [MVP]

Hi Joe,

yeah, I know I can do that. I was hoping to avoid that somehow.

Maybe the way to do this is to use TLBIMP and then decompile the code it
gens? I suspect that sin't going to work on that code because of all the
Attributes requirement to the COM interop stuff work.


+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
 
J

Joe Mayo [C# MVP]

Rick Strahl said:
Hi Joe,

yeah, I know I can do that. I was hoping to avoid that somehow.

Maybe the way to do this is to use TLBIMP and then decompile the code it
gens? I suspect that sin't going to work on that code because of all the
Attributes requirement to the COM interop stuff work.


That's a thought. I haven't used the Anakrino decompiler, but have seen
some people recommend it:

http://www.saurik.com/

Joe
 
M

Mattias Sjögren

Rick,

Aurigma had a tool that generated source code instead of compiled
assemblies (at http://www.aurigma.com/Products/COMtoNET/) that used to
be available in public beta, but it doesn't appear to be anymore.

You can't use Reflection to build your own interop assembly
decompiler, because Reflection doesn't return interop related metadata
(at least not in pre-Whidbey versions).

I've been working on a decompiler that uses the unmanaged metadata
APIs instead. It's not finished, but it may be good enough if you're
interested.



Mattias
 
J

Jonathan Pierce

Our Decompiler.NET product fully supports generating COM interface
sources from compiled .NET assemblies. It reads custom attributes and
metadata such as FieldMarshal Info, Struct Layout attributes,
DllImport attributes, etc. directly from the PE file. You can download
a free trial version and see how well it works from
http://www.junglecreatures.com/

Jonathan Pierce
President
Jungle Creatures, Inc.
http://www.junglecreatures.com/
Email: (e-mail address removed)/
 
A

Al Ponomarev

Any decompiler can't produce real same code of produced TLBIMP utility -
Try this - open interop assembly in the ildasm and see the attributes of
some methods of some COM interface - you'll see <internalcall> attribute -
it means that this method will execute thru .Net VM.
This attribute - is internal for .net framework attribute that you can't
atach to source, unfortunately :(
I've experimented with the Text Object Model (TOM) but have no good results
with using decompiled from tom.dll produced by tlbimp.

--
Best regards,
Victor Victorov
Spices.Net - class browser, decompiler, obfuscator, modeler for your .Net
apps.
9Rays.Net
 
R

Roland

The issue is not the internalcall but the fact that it is also marked
"runtime".

However, in all cases that I ran into this hasnt been a problem so far. If
you know what you're doing it really works like charm.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top