regasm does not expose methods or properties to COM 
Author Message
 regasm does not expose methods or properties to COM

My understanding is that I can run regasm on an assembly to produce a
component
visible to COM. (I need to use an assembly from Excel/VBA).  The component
appears fine, BUT there are a few annoying 'limitations':

    - OLEVIEW cannot read the generated type library
    - None of the methods or properties appear, looks as though there not
being exported
       by regasm...

Surely this is either (a) a very serious bug or (b) there's a trick?

I tried it on a few samples - the lethods/properties are NEVER exported.

James Battle

Ironbark Limited
Greenwood House
4/7 Salisbury Court
London EC4Y 8BT

Tel: +44 (0) 777 594 6279
Fax: +44 (0) 20 8789 3358
Web: http://www.*-*-*.com/



Mon, 30 Aug 2004 04:32:51 GMT  
 regasm does not expose methods or properties to COM
James,

    I think it is a trick =P

    In all seriousness, are you tagging your classes in the assembly
correctly to export the interface definitions?  By default, with no
attributes, the class will only export the IDispatch interface, allowing it
to be called from script and late-bound.

    What you probably want to do is apply the ClassInterfaceAttribute to
your class, with a value of ClassInterfaceType.AutoDual being passed to the
constructor.  Also, you probably want to define the Guid for the class.

    It has been noted that a better design is to create an interface that
represents your class and then export that to COM, as well as a co-class
definition that says it implements the interface in question.  The reason
for this is because COM interfaces are supposed to be immutable, and if you
change a method signature, you are going to break that rule.

    Hope this helps.

--
               - Nicholas Paldino [.NET MVP]


Quote:

> My understanding is that I can run regasm on an assembly to produce a
> component
> visible to COM. (I need to use an assembly from Excel/VBA).  The component
> appears fine, BUT there are a few annoying 'limitations':

>     - OLEVIEW cannot read the generated type library
>     - None of the methods or properties appear, looks as though there not
> being exported
>        by regasm...

> Surely this is either (a) a very serious bug or (b) there's a trick?

> I tried it on a few samples - the lethods/properties are NEVER exported.

> James Battle

> Ironbark Limited
> Greenwood House
> 4/7 Salisbury Court
> London EC4Y 8BT

> Tel: +44 (0) 777 594 6279
> Fax: +44 (0) 20 8789 3358
> Web: http://www.ironbark.co.uk



Mon, 30 Aug 2004 04:45:51 GMT  
 regasm does not expose methods or properties to COM
Yeah, I noticed some of these suggesstions on the 'Late breaking Issues'
pages.  To me this effectively says that COM INTEROP does not work.

Unless I am very stupid, nobody is going to want to play around with .NET
so that they can write COM components.  The problem is that COM-based
apps like Excel will be around for a long time and hence they HAVE to be
supported.

It reminds me of the mess that is calling C from Java.

I hope there's a better way.

James Battle

Ironbark Limited
Greenwood House
4/7 Salisbury Court
London EC4Y 8BT

Tel: +44 (0) 777 594 6279
Fax: +44 (0) 20 8789 3358
Web: http://www.ironbark.co.uk



Quote:
> James,

>     I think it is a trick =P

>     In all seriousness, are you tagging your classes in the assembly
> correctly to export the interface definitions?  By default, with no
> attributes, the class will only export the IDispatch interface, allowing
it
> to be called from script and late-bound.

>     What you probably want to do is apply the ClassInterfaceAttribute to
> your class, with a value of ClassInterfaceType.AutoDual being passed to
the
> constructor.  Also, you probably want to define the Guid for the class.

>     It has been noted that a better design is to create an interface that
> represents your class and then export that to COM, as well as a co-class
> definition that says it implements the interface in question.  The reason
> for this is because COM interfaces are supposed to be immutable, and if
you
> change a method signature, you are going to break that rule.

>     Hope this helps.

> --
>                - Nicholas Paldino [.NET MVP]



> > My understanding is that I can run regasm on an assembly to produce a
> > component
> > visible to COM. (I need to use an assembly from Excel/VBA).  The
component
> > appears fine, BUT there are a few annoying 'limitations':

> >     - OLEVIEW cannot read the generated type library
> >     - None of the methods or properties appear, looks as though there
not
> > being exported
> >        by regasm...

> > Surely this is either (a) a very serious bug or (b) there's a trick?

> > I tried it on a few samples - the lethods/properties are NEVER exported.

> > James Battle

> > Ironbark Limited
> > Greenwood House
> > 4/7 Salisbury Court
> > London EC4Y 8BT

> > Tel: +44 (0) 777 594 6279
> > Fax: +44 (0) 20 8789 3358
> > Web: http://www.ironbark.co.uk



Mon, 30 Aug 2004 04:57:43 GMT  
 regasm does not expose methods or properties to COM
James,

    What I suggested is NOT a workaround, rather, it is the way that COM
interop works.  The suggestion in the last paragraph was just that, a
suggestion, it is not mandatory for COM interop.

    Also, COM is an INTERFACE-BASED (I can not stress this enough)
framework, so the last suggestion is not so far fetched.  VB6 just
obfuscated this fact from it's user base.

    Are you placing the following before your class definition?

[ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]

    If not, then you will never see the interfaces on your classes.

--
               - Nicholas Paldino [.NET MVP]


Quote:
> Yeah, I noticed some of these suggesstions on the 'Late breaking Issues'
> pages.  To me this effectively says that COM INTEROP does not work.

> Unless I am very stupid, nobody is going to want to play around with .NET
> so that they can write COM components.  The problem is that COM-based
> apps like Excel will be around for a long time and hence they HAVE to be
> supported.

> It reminds me of the mess that is calling C from Java.

> I hope there's a better way.

> James Battle

> Ironbark Limited
> Greenwood House
> 4/7 Salisbury Court
> London EC4Y 8BT

> Tel: +44 (0) 777 594 6279
> Fax: +44 (0) 20 8789 3358
> Web: http://www.ironbark.co.uk


in

> > James,

> >     I think it is a trick =P

> >     In all seriousness, are you tagging your classes in the assembly
> > correctly to export the interface definitions?  By default, with no
> > attributes, the class will only export the IDispatch interface, allowing
> it
> > to be called from script and late-bound.

> >     What you probably want to do is apply the ClassInterfaceAttribute to
> > your class, with a value of ClassInterfaceType.AutoDual being passed to
> the
> > constructor.  Also, you probably want to define the Guid for the class.

> >     It has been noted that a better design is to create an interface
that
> > represents your class and then export that to COM, as well as a co-class
> > definition that says it implements the interface in question.  The
reason
> > for this is because COM interfaces are supposed to be immutable, and if
> you
> > change a method signature, you are going to break that rule.

> >     Hope this helps.

> > --
> >                - Nicholas Paldino [.NET MVP]



> > > My understanding is that I can run regasm on an assembly to produce a
> > > component
> > > visible to COM. (I need to use an assembly from Excel/VBA).  The
> component
> > > appears fine, BUT there are a few annoying 'limitations':

> > >     - OLEVIEW cannot read the generated type library
> > >     - None of the methods or properties appear, looks as though there
> not
> > > being exported
> > >        by regasm...

> > > Surely this is either (a) a very serious bug or (b) there's a trick?

> > > I tried it on a few samples - the lethods/properties are NEVER
exported.

> > > James Battle

> > > Ironbark Limited
> > > Greenwood House
> > > 4/7 Salisbury Court
> > > London EC4Y 8BT

> > > Tel: +44 (0) 777 594 6279
> > > Fax: +44 (0) 20 8789 3358
> > > Web: http://www.ironbark.co.uk



Mon, 30 Aug 2004 05:08:32 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. exposing activex control methods and properties?

2. Howto Expose a normal C++ class with methods via an Interface Class in ATL COM

3. simple ole.com sample requested / no methods exposed

4. Exposing methods which pass arrays to COM interop

5. WMI Instrumented object methods not exposed

6. Class not registered when doing COM interop

7. list of Properties and Methods of a COM object

8. methods/properties does not popup?

9. Can not find property & method of interface

10. ActiveX (OCX control) - Hierarchical properties and methods do not appear in VB5

11. COM method returning, but not to caller

12. Overloading Methods exposed through an Interface

 

 
Powered by phpBB® Forum Software