Re: Consuming a .NET class exposed through COM?



Yes I have done this in .Net 2.0 using VisualStudio.

There are a couple threads out there that are helpful but mostly they talk
about 1.1.

Youj need to generate a TLB from your .Net assembly, and get it registered
in the Registry. Then the class needs to implement an Interface that has a
GUID and itself has an attribute that disables the default generated
interface. The tool you want is regasm. Your use of auto dual might work
as well, but the example I had used an explicit interface so you could
request the interface from the IDispatch inside Dolphin.

I had planed to take this farther and build a general framework for .Net
interop, but get derailed by a large contracting project. The performance
on this is not all that good. This is on the order of 50X the Smalltalk
dispatch speed. It was recommended to me to look at managed C++ which could
provide a more efficient interop path than COM and could be used with the
CLR hosting tools.

If you GOOGLE "CLR Hosting" you should find several good articles.

Michael



"Griff" <grettke@xxxxxxx> wrote in message
news:1153173274.202336.196080@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I've previously written a .NET 1.1 class that is exposed through COM by
using

1. Class attribute [Guid("guid-here")]
2. Class attribute [ClassInterface(ClassInterfaceType.AutoDual)]
3. Implementing the class to be COM compliant language friendly (no
exceptions, or constructors), specifically VB6
4. Generating a strong name key file
5. In the assemblyinfo.cs: locking the version to 1.0.0.0 and
specifying no-delay signing along with the key file
6. Created an installer to register this dll as a COM compatible and
consequently a type library entry for it so COM clients would be happy

This was deployed and works great with VB6. I've tried the same thing
with .NET 2.0 and D6, but it fails to open the DLL with a walkback
starting with "HRESULT Error: Error loading type library/DLL".

Right now I am thinking that I could:
1. Try this with VS.NET 2003, .NET 1.1
2. Try to find more documentation about how to do this in .NET 2.0,
seemingly it is easier now
3. Find someone else who has already accomplished this

So, have any of you already tried this successfully with either .NET
1.1 or 2.0?



.



Relevant Pages

  • Re: Creating object inside an ISAPI DLL - does registry settings required?
    ... interface needs hand-coding in ATL. ... > ActiveX implementation so the same DLL can server both purposes (that will ... > the ISAPI Dll does not utilize any sytem resources such as registry). ... > ATL IDispatch implementation is based on type library, ...
    (microsoft.public.vc.atl)
  • Re: DLL registering problem in WinCE..
    ... The *interface* wouldn't be in the registry. ... Use debug messages to see what pieces of your DLL ... >> Paul T. ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: .NET and COM
    ... The entry point sits in the main DLL but depending on the needed instruments one of the AddOn-DLL?s is loaded. ... Every DLL exports a special interface (IOleInstrument). ... In case of C++ this interface is registered as IOleInterface in the registry but in case of the C# DLL the interface is registered as RdrOle4AddOn6.Instrument (which is a combination of the name of the namespace ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: For the AdaOS folks
    ... gone beyond the registry in proposed solutions yet. ... > abuses, and secondly, we could define somewhere an abstract interface to be ... Yes of course - ie. it must support the Ada RTL, ...
    (comp.lang.ada)
  • Re: Dynamic DNS
    ... > an IP reserved by RRAS for dial-in clients. ... internal interface is at the top of the list and that Client for MS Networks ... Registry value: DnsAvoidRegisterRecords ...
    (microsoft.public.win2000.dns)