Com connection

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

Hi,
Can any one tell me what`s the diffrent bettwin the two configuration to
expose a C# class to a com object:

[Guid("B6F829AA-D1D0-4f14-9B3E-D8D4FA033819")]

public class ConfigurationBuilder : IConfigurationBuilder

{...}



[ClassInterface(ClassInterfaceType.None)]

public class ConfigurationBuilder : IConfigurationBuilder

{...}

when should i use GUID and when should i use the ClassInterfaceType
attribute and whate the comoiler do with this attribute?

Thanks.
 
Dave,

You should actually be using BOTH of these attributes, as they both do
different things. The Guid attribute on the class is going to declare what
the CLSID of the COM component will be. The ClassInterface attribute will
indicate that the class will not export an interface of its own. They
should both be on there.

Hope this helps.
 
And what is the advantage of declaring a CLSID vs. letting the VS create
one?

Do we need a different CLSID for every class, or only one for the dll?

Francis
 
Francis,

When you let .NET create the CLSID, it will create a new one every time
you build the application. This can get quite messy, and locating the
registry entries (if you have to) can be a pain.

You will need to create one for every class that you plan on exporting
to COM, as well as every interface you want to export to COM.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Francis Gingras said:
And what is the advantage of declaring a CLSID vs. letting the VS create
one?

Do we need a different CLSID for every class, or only one for the dll?

Francis

message news:[email protected]...
 
Back
Top