473,761 Members | 9,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Interface inheritence and COM

yoz
Hi everyone,

I wonder if you can shed some light on a problem I have. I am
exporting a C# .Net set of classes to COM. All of it is exported
properly but the interface inheritences are not in the type library.

for example:

public interface IA
{
void proc1();
}

public interface IB: IA
{
void proc2();
}

In the type library IA and IB BOTH descend from IDispatch. Is there an
attribute to say that when tlbexp.exe generate the type library, it
makes IB descend from IA?

Regards
Nov 15 '05 #1
4 3902
Have you tried using - [ClassInterface( ClassInterfaceT ype.AutoDual)]
"yoz" <ne******@hotma il.com> wrote in message
news:21******** *************** ***@posting.goo gle.com...
Hi everyone,

I wonder if you can shed some light on a problem I have. I am
exporting a C# .Net set of classes to COM. All of it is exported
properly but the interface inheritences are not in the type library.

for example:

public interface IA
{
void proc1();
}

public interface IB: IA
{
void proc2();
}

In the type library IA and IB BOTH descend from IDispatch. Is there an
attribute to say that when tlbexp.exe generate the type library, it
makes IB descend from IA?

Regards

Nov 15 '05 #2
Hi Yoz,

When you look at the .NET class that's exposed to COM, what is its
ClassInterfaceT ype attribute set to? This is one way of controlling
versioning issues when a COM client consumes a .NET component.

ClassInterfaceT ype.AutoDispatc h is the default. It is friendly about COM
versioning, but at the cost of allowing only late-bound COM clients and
potential bugs that won't be found until run-time. Your COM client will be
late-bound. This may be what you're seeing currently.

ClassInterfaceT ype.AutoDual allows early-bound COM clients and compile-time
checking, but completely ignores COM versioning, meaning that you should
(and may have to) recompile your COM clients every time the .NET component
is changed.

ClassInterfaceT ype.None together with a separation of the class interface
from its implementation gives you the best of both worlds: early binding and
compile-time checking together with the flexibility to change the .NET
component. I believe that there's an example in the docs that shows you how
to do this.

HTH,

Mark
--
Author of "Comprehens ive VB .NET Debugging"
http://www.apress.com/book/bookDisplay.html?bID=128
"yoz" <ne******@hotma il.com> wrote in message
news:21******** *************** ***@posting.goo gle.com...
Hi everyone,

I wonder if you can shed some light on a problem I have. I am
exporting a C# .Net set of classes to COM. All of it is exported
properly but the interface inheritences are not in the type library.

for example:

public interface IA
{
void proc1();
}

public interface IB: IA
{
void proc2();
}

In the type library IA and IB BOTH descend from IDispatch. Is there an
attribute to say that when tlbexp.exe generate the type library, it
makes IB descend from IA?

Regards
Nov 15 '05 #3
yoz
OK I think I understand what C# wants.

I created an interface, and implemented it in the class to export. C#,
however, creates an "_" (underscore) interface for each object, and instead
of deriving interaces it put the whole ancestry public methods and
properties in every interface. The problem is that you cannot specify the
GUID of the "_" interface so it changes everytime you compile. Thus that is
why late binding always work, however application need to be recompile if my
..NET COM Module is compile with early binding.

Do I got it right?

I am sorry to sound ignorant but if it is, why can't you keep the same GUID?
Is that a design feature because I find it very stupid... I come from
Delphi, but I remember VB guys I work with told me that VB6 also change the
GUID at every compile but I was also told you can stop that.... Is there a
way to stop that under C#?

"Mark Pearce" <ev**@bay.com > wrote in message
news:Oa******** ******@tk2msftn gp13.phx.gbl...
Hi Yoz,

When you look at the .NET class that's exposed to COM, what is its
ClassInterfaceT ype attribute set to? This is one way of controlling
versioning issues when a COM client consumes a .NET component.

ClassInterfaceT ype.AutoDispatc h is the default. It is friendly about COM
versioning, but at the cost of allowing only late-bound COM clients and
potential bugs that won't be found until run-time. Your COM client will be
late-bound. This may be what you're seeing currently.

ClassInterfaceT ype.AutoDual allows early-bound COM clients and compile-time checking, but completely ignores COM versioning, meaning that you should
(and may have to) recompile your COM clients every time the .NET component
is changed.

ClassInterfaceT ype.None together with a separation of the class interface
from its implementation gives you the best of both worlds: early binding and compile-time checking together with the flexibility to change the .NET
component. I believe that there's an example in the docs that shows you how to do this.

HTH,

Mark
--
Author of "Comprehens ive VB .NET Debugging"
http://www.apress.com/book/bookDisplay.html?bID=128
"yoz" <ne******@hotma il.com> wrote in message
news:21******** *************** ***@posting.goo gle.com...
Hi everyone,

I wonder if you can shed some light on a problem I have. I am
exporting a C# .Net set of classes to COM. All of it is exported
properly but the interface inheritences are not in the type library.

for example:

public interface IA
{
void proc1();
}

public interface IB: IA
{
void proc2();
}

In the type library IA and IB BOTH descend from IDispatch. Is there an
attribute to say that when tlbexp.exe generate the type library, it
makes IB descend from IA?

Regards

Nov 15 '05 #4
Hi Yoz,

Look at the GuidAttribute design-time attribute in the MSDN documentation.
This attribute allows you to specify a guid for a class, interface or
complete type library, and this guid can be kept even when you change your
interface.

HTH,

Mark
--
Author of "Comprehens ive VB .NET Debugging"
http://www.apress.com/book/bookDisplay.html?bID=128
"yoz" <netfever@hot_R EMOVE_SPAM_mail .com> wrote in message
news:%U******** ***********@new s-binary.blueyond er.co.uk...
OK I think I understand what C# wants.

I created an interface, and implemented it in the class to export. C#,
however, creates an "_" (underscore) interface for each object, and instead
of deriving interaces it put the whole ancestry public methods and
properties in every interface. The problem is that you cannot specify the
GUID of the "_" interface so it changes everytime you compile. Thus that is
why late binding always work, however application need to be recompile if my
..NET COM Module is compile with early binding.

Do I got it right?

I am sorry to sound ignorant but if it is, why can't you keep the same GUID?
Is that a design feature because I find it very stupid... I come from
Delphi, but I remember VB guys I work with told me that VB6 also change the
GUID at every compile but I was also told you can stop that.... Is there a
way to stop that under C#?

"Mark Pearce" <ev**@bay.com > wrote in message
news:Oa******** ******@tk2msftn gp13.phx.gbl...
Hi Yoz,

When you look at the .NET class that's exposed to COM, what is its
ClassInterfaceT ype attribute set to? This is one way of controlling
versioning issues when a COM client consumes a .NET component.

ClassInterfaceT ype.AutoDispatc h is the default. It is friendly about COM
versioning, but at the cost of allowing only late-bound COM clients and
potential bugs that won't be found until run-time. Your COM client will be
late-bound. This may be what you're seeing currently.

ClassInterfaceT ype.AutoDual allows early-bound COM clients and compile-time checking, but completely ignores COM versioning, meaning that you should
(and may have to) recompile your COM clients every time the .NET component
is changed.

ClassInterfaceT ype.None together with a separation of the class interface
from its implementation gives you the best of both worlds: early binding and compile-time checking together with the flexibility to change the .NET
component. I believe that there's an example in the docs that shows you how to do this.

HTH,

Mark
--
Author of "Comprehens ive VB .NET Debugging"
http://www.apress.com/book/bookDisplay.html?bID=128
"yoz" <ne******@hotma il.com> wrote in message
news:21******** *************** ***@posting.goo gle.com...
Hi everyone,

I wonder if you can shed some light on a problem I have. I am
exporting a C# .Net set of classes to COM. All of it is exported
properly but the interface inheritences are not in the type library.

for example:

public interface IA
{
void proc1();
}

public interface IB: IA
{
void proc2();
}

In the type library IA and IB BOTH descend from IDispatch. Is there an
attribute to say that when tlbexp.exe generate the type library, it
makes IB descend from IA?

Regards


Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
1908
by: Pierre Barbier de Reuille | last post by:
Ok, I first want to stress that I looked through the newsgroups archives (on Google) for an answer to my question, but I didn't find it. It's about the interface of the set classes as defined in the PEP 218. I don't understand why the sets has an interface of mapping object without associated value and not an interface of sequence ? For me, sets are first sequences. I use set where lists are inefficient or inadapted, for example when I...
5
24228
by: TruongLapVi | last post by:
Hi, Why C# does not support Interface static member ? Some time I want implement NullObject Pattern: public interface INullObject { public static INullObject Null { get { return NullObject.Instance; } // !!! Wrong, C# not support ? }
26
2104
by: Marius Horak | last post by:
As in subject. Thanks MH
0
1121
by: cs_hart | last post by:
After converting a java application to c# using the microsoft conversion assistant, I get multiple errors "type in interface list is not an interface". From reading other posts it appears that this is due to multiple inheritence. public interface Document extends Datum, List -----CONVERTS TO----- public interface Document : Datum, SupportClass.ListCollectionSupport Since I don't want to redesign the application, is there another
15
12790
by: jon | last post by:
How can I call a base interface method? class ThirdPartyClass :IDisposable { //I can not modify this class void IDisposable.Dispose() { Console.WriteLine( "ThirdPartyClass Dispose" ); } } class MyClass :ThirdPartyClass, IDisposable { void IDisposable.Dispose() {
0
873
by: Michelangelo | last post by:
Hello, I want to build a class library with baseclasses. The classes that inherit from these baseclasses will get a COM-interface. I use the following way: *************** REM BaseClass.dll: Interface_MyBaseClass ' No COM-interface here. MyMethod() End Interface
5
10377
by: LS | last post by:
Can a WebMethod return an Interface type? Can we pass an interface parameter ? Example : public interface IEntity { long Id { get; set; } string Name { get; set; } }
17
2284
by: Zytan | last post by:
Aren't all classes interfaces? What constitutes an interface (and with it, the "I" prefix distinction)? Zytan
11
1299
by: Wayne Pedersen | last post by:
Need some help - and I may be doing this wrong, so please correct and suggest! I'm learning the MVP method, which I seem to have a good grasp of. Now I am trying something a bit more advanced. I'm declaring an event in a interface. I'm consuming the interface via another inherited Interface. I'd like to have my classes respond to this 'one' event... Based on my below example code, I'd like both Classes Test1 and Test2 to
0
9345
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9775
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7332
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5229
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3881
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.