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 / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

dotnet to com

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Filip Fransen - 21 Sep 2007 19:04 GMT
Hi,

I have a to create a com object from a dotnet class. Now I have the
following questions :
- with Queryinterface you can get all the interfaces from a com app. How can
I expose my dotnet classes with Queryinterface.
- I can convert a dotnet class with Marshal.GetIUnknowFromObject. Is it
possible to override the queryinterface method in the dotnet class.

Thx

Filip
Nicholas Paldino [.NET/C# MVP] - 21 Sep 2007 19:58 GMT
Filip,

   Basically, you want to know how you can have multiple interfaces served
up from your COM object implementation in .NET.

   When creating the class in .NET which you want to be exposed to COM, you
want to attach the following attribute to your class:

[ClassInterface(ClassInterfaceType.None)]
[Guid(...)]
public class MyClass
{ ... }

   This will cause your class to not publish an interface based on the
members of your class, but rather, based on any interface implementations
that it implements.

   Then, you want to create your interfaces, like so:

[Guid(...)]
public interface IDoSomething
{ ... }

   With all the marshalling goo applied.  Then, you just implement the
interface on your class.  The reason it's important to place the Guid
attribute on the class is so that you have control over the class id of your
type.  The reason it is important on the interface is so you have control
over the interface id which is needed when you make your calls to
QueryInterface.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi,
>
[quoted text clipped - 8 lines]
>
> Filip

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.