Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / May 2004

Tip: Looking for answers? Try searching our database.

COM -> CSharp Interface generator

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rick Strahl [MVP] - 26 Apr 2004 01:25 GMT
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 ---

Signature

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web

Joe Mayo [C# MVP] - 26 Apr 2004 02:13 GMT
> 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
[quoted text clipped - 3 lines]
> 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
Signature

http://www.csharp-station.com

Rick Strahl [MVP] - 26 Apr 2004 05:24 GMT
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 ---

Signature

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web

> > 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
[quoted text clipped - 14 lines]
>
> Joe
Joe Mayo [C# MVP] - 26 Apr 2004 05:42 GMT
> Hi Joe,
>
[quoted text clipped - 3 lines]
> 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
Signature

http://www.csharp-station.com

Roland - 06 May 2004 02:20 GMT
Anakrino isnt really useful for getting C# for COM interfaces. The
FileDisassembler add-in at http://www.denisbauer.com/NETTools/ does a really
good job on this as I just found out :-)

> > Hi Joe,
> >
[quoted text clipped - 10 lines]
>
> Joe
Mattias Sj?gren - 26 Apr 2004 09:57 GMT
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

Signature

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

PEACEMAKER - 26 Apr 2004 04:30 GMT
doesn't visual studio 7.1 have this built in? where it imports an com
interface for you to use in c#?
> 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
[quoted text clipped - 5 lines]
>
> +++ Rick ---
Rick Strahl [MVP] - 26 Apr 2004 05:23 GMT
Yeah TLBIMP does, but it doesn't generate the source for it. It's all or
nothing. I need to pull in a few interfaces of a huge type library and don't
want the baggage of a 7meg file...

+++ Rick ---

Signature

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web

> doesn't visual studio 7.1 have this built in? where it imports an com
> interface for you to use in c#?
[quoted text clipped - 9 lines]
> >
> > +++ Rick ---
Jonathan Pierce - 28 Apr 2004 00:00 GMT
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: support@junglecreatures.com/
Roland - 06 May 2004 02:24 GMT
You can use the FileDisassembler add-in for Reflector (available at
http://www.denisbauer.com/NETTools/)

> Our Decompiler.NET product fully supports generating COM interface
> sources from compiled .NET assemblies. It reads custom attributes and
[quoted text clipped - 8 lines]
> http://www.junglecreatures.com/
> Email: support@junglecreatures.com/
Al Ponomarev - 30 Apr 2004 22:12 GMT
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
Roland - 06 May 2004 02:27 GMT
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.

> 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
[quoted text clipped - 11 lines]
> apps.
> 9Rays.Net

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.