Hi
I don't want to factor out my public functionality into interfaces,
suppress the ClassInterface, use ClassInterfaceType.None and
ComInterfaceType.InterfaceIsIUnknown as attributes just to find that
when I use OleView my pretend coclasses implement some mysterious
interface _Object which my 1990s-style COM clients have never heard of!
So, help me get retro'! I want my C# class to forget all about
System.Object when it exposes itself in a type library.
Help me get rid of this sort of thing!
coclass Distribution
{
[default] interface IDistributionInfo;
interface _Object;
};
OK, this isn't the end of the world but it's been driving me mad for a
couple of days now: I want my COM clients to spend their golden years
not worrying about modern developments :-)
Emma
Egbert Nierop (MVP for IIS) - 24 Sep 2005 23:12 GMT
> Hi
>
[quoted text clipped - 8 lines]
>
> Help me get rid of this sort of thing!
you won't. regasm just creates this stuff for you.
If you want to do it otherwise, you'll have to use MC++ and create and
compile your own IDL.
b.t.w. since IDistributionInfo is really the -default- interface, your 1990+
clients should not bother about secundary interfaces. Vbscript for instance,
is a 1990 COM client :) and really will not care about non-primary
interfaces. It will however, always use the dispatch interface (which is
default as well).
> coclass Distribution
> {
[quoted text clipped - 7 lines]
>
> Emma
emma_middlebrook@fastmail.fm - 25 Sep 2005 18:33 GMT
> > Hi
> >
[quoted text clipped - 19 lines]
> interfaces. It will however, always use the dispatch interface (which is
> default as well).
Hi
Thanks for you reply. I take your point regarding the primary
interface: _Object's presence is no big deal in practice. Just out of
interest - can you think of any good reason why it should be there at
all? I wouldn't expect any of Object's methods to be of any use to COM
clients rather, they are a bit irrelevant. I wouldn't like to see the
clients QIing for it! Was just hoping I could clear _Object right out
of the type library using some kind of attribute or other i.e. not
resorting to get MIDL out after I put it away a couple of years ago :-)
Cheers though
Emma
Egbert Nierop (MVP for IIS) - 24 Sep 2005 23:14 GMT
> Hi
>
[quoted text clipped - 9 lines]
> interface _Object;
> };
ps: did you define your IDistributionInfo with a Dual Interface?
(for instance)
[GuidAttribute ("127DA1EE-DE83-46FF-ACFB-C4EB3D721234"),
InterfaceType(ComInterfaceType.InterfaceIsDual)]
[TypeLibType(TypeLibTypeFlags.FOleAutomation)]
public interface utcIFace
{
DateTime InterpreteDate(string sDate);
}
etc...
emma_middlebrook@fastmail.fm - 25 Sep 2005 18:39 GMT
> > Hi
> >
[quoted text clipped - 26 lines]
>
> }
Hi - no, it's IUnknown - you can see from the original posting.
You pointed out something interesting I'd not seen before: I wonder if
fiddling with TypeLibTypeFlags might come up with something!
Another question though - is it possible to apply an attribute to
something *not* at its point of definition. e.g. Maybe I could apply
COMVisible(false) to System.Object somehow but I don't have enough
knowledge to do so.
Well I'm still thinking about this :-))
Cheers
Emma
Egbert Nierop (MVP for IIS) - 25 Sep 2005 19:01 GMT
>> }
>
[quoted text clipped - 9 lines]
>
> Well I'm still thinking about this :-))
If you press F2 (in VB6) you'll only see interfaces and objects that are not
prefixed with _ and have not the [restricted] attribute (IDL). So in VB6 you
won't see the _Object interface. But it might be that pascal or delphi still
shows them up. I would not bother, Just care for it, that your primary
interface -is- a dual interface and that your primary class, that inherits
your Dual interface, has this
[InterfaceType(ComInterfaceType.None)]
So your Ole Automation clients, will work like a shining sun :)
> Cheers
>
> Emma
emma_middlebrook@fastmail.fm - 26 Sep 2005 12:04 GMT
> >> }
> >
[quoted text clipped - 20 lines]
>
> So your Ole Automation clients, will work like a shining sun :)
Egbert
Thanks for reminding me about the _ trick on interfaces: it's been so
long since I did any of this stuff but, now, I remember at one place I
worked we did this for certain IDL defined interfaces so VB6 couldn't
see.
I'll rest easy now!
Cheers
Emma