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 / Interop / September 2005

Tip: Looking for answers? Try searching our database.

hiding System.Object from COM ??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
emma_middlebrook@fastmail.fm - 20 Sep 2005 15:07 GMT
Hi

I'm exposing a simple VB.NET object for use by COM.

If I expose the class using the following attribute

System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDual)>

then in the .tlb file I get all the System.Object methods ...

Any ideas how I can suppress this easily please?

Cheers

Emma Middlebrook

  interface _Exposed : IDispatch {
       [id(00000000), propget,
           custom({54FC8F55-38DE-4703-9C4E-250351302B1C}, "1")]
       HRESULT ToString([out, retval] BSTR* pRetVal);
       [id(0x60020001)]
       HRESULT Equals(
                       [in] VARIANT obj,
                       [out, retval] VARIANT_BOOL* pRetVal);
       [id(0x60020002)]
       HRESULT GetHashCode([out, retval] long* pRetVal);
       [id(0x60020003)]
       HRESULT GetType([out, retval] _Type** pRetVal);
   };
Robert Jordan - 20 Sep 2005 15:17 GMT
> Hi
>
[quoted text clipped - 7 lines]
>
> Any ideas how I can suppress this easily please?

Use ClassInterfaceType.AutoDispatch.

Rob
emma_middlebrook@fastmail.fm - 20 Sep 2005 15:24 GMT
Thanks very much for your reply but I would really like the members to
be visible. Rather than going through all the hassle of GetIDsOfNames
and Invoke and so on!

If I understand correctly AutoDispatch will mean I can no longer see
anything for early binding purposes.

Is that true?

Emma
Robert Jordan - 20 Sep 2005 17:35 GMT
> Thanks very much for your reply but I would really like the members to
> be visible. Rather than going through all the hassle of GetIDsOfNames
[quoted text clipped - 4 lines]
>
> Is that true?

Yes. Now I unterstand what you want to achieve.

You have to define an interface with the methods you want to
expose and let your class implement that interface.
In this case you have to use ClassInterfaceType.None.

Rob
emma_middlebrook@fastmail.fm - 20 Sep 2005 19:39 GMT
> > Thanks very much for your reply but I would really like the members to
> > be visible. Rather than going through all the hassle of GetIDsOfNames
[quoted text clipped - 10 lines]
> expose and let your class implement that interface.
> In this case you have to use ClassInterfaceType.None.

Robert

Thanks very much for your reply again and sorry I didn't make myself
properly clear before. I did read MSDN and so roughly tried to do what
you suggest i.e. I got the class to implement an interface that I
wished to expose (without System.Object stuff) and tried it out. It
didn't seem to work but thinking about it, it might be because I didn't
explicitly use None thinking that it might be the default. Am at home
now but will have another look tomorrow!

Thanks for you help

Emma
emma_middlebrook@fastmail.fm - 21 Sep 2005 10:30 GMT
Hi

Your advice worked perfectly. Thankyou. I now have my class as follows
in the type library:

coclass DistributionFactory {
   interface _Object;
   [default] interface IDistributionFactory;
};

Now I have two further questions!

1. Is there a way to remove the superfluous (for us) _Object interface?

2. Would anyone be able to suggest a reason why unmanaged code would
ever want to make use of that interface?

Many thanks to the newsrgoup!

Emma

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.