473,396 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

COM interfaces issues: Please help!

Hi,

I have a class with some functions that I want to be available via COM
interop. I declared the interface, which the class is based on, like this:

[Guid("F2B5A004-9D1C-4fba-B8BE-D7C6B08618CD")]
public interface IA
{
[DispId(1)]
string Test();

[DispId(2)]
bool SaveChanges();

[DispId(3)]
bool SendResults();
}

Now, I want my class to also implement a second interface which is located
in another assembly (another C# project to which I made a reference in my
current project) that has the following definition:

public interface IB
{
bool UpdateInformation();
}

I don't want any functions or properties from IB to be exported or available
through COM interop. Basically, I then defined my class like this:

[Guid("AAC98A5E-8AA5-49fb-B0D7-EE6E6902D1B8"),
ClassInterface(ClassInterfaceType.None)]
public class MyClass : IA, ExternalNamespace.IB
{ ... }

I made sure to implement every function from both interfaces. Now, when I
try to compile this solution without the "Register for COM interop" set to
true, everything is fine. But if I set the option to true, I get the
following error when compiling my current project (the one with the class
implementing the two interfaces):

COM Interop registration failed. Could not find a type library for assembly
'X'.

'X' is my external project referenced in the current project (it compiles to
a Class Library and does not have anything related to COM interop in it).

Why am I getting this error and how can I have a class inherit two
interfaces with only one enabled for COM interop.

Thanks a lot,

Skip.

Nov 16 '05 #1
2 1077
Skip:

I've not tried this, but perhaps you can use the ComVisible attribute to
specifically hide the IB interface from COM interop? It appears from a
quick look at the doc that you can apply ComVisible fairly granularly.

Anyone else have thoughts on this?

John
"Skip" <Sk**@discussions.microsoft.com> wrote in message
news:AA**********************************@microsof t.com...
Hi,

I have a class with some functions that I want to be available via COM
interop. I declared the interface, which the class is based on, like this:
[Guid("F2B5A004-9D1C-4fba-B8BE-D7C6B08618CD")]
public interface IA
{
[DispId(1)]
string Test();

[DispId(2)]
bool SaveChanges();

[DispId(3)]
bool SendResults();
}

Now, I want my class to also implement a second interface which is located
in another assembly (another C# project to which I made a reference in my
current project) that has the following definition:

public interface IB
{
bool UpdateInformation();
}

I don't want any functions or properties from IB to be exported or available through COM interop. Basically, I then defined my class like this:

[Guid("AAC98A5E-8AA5-49fb-B0D7-EE6E6902D1B8"),
ClassInterface(ClassInterfaceType.None)]
public class MyClass : IA, ExternalNamespace.IB
{ ... }

I made sure to implement every function from both interfaces. Now, when I
try to compile this solution without the "Register for COM interop" set to
true, everything is fine. But if I set the option to true, I get the
following error when compiling my current project (the one with the class
implementing the two interfaces):

COM Interop registration failed. Could not find a type library for assembly 'X'.

'X' is my external project referenced in the current project (it compiles to a Class Library and does not have anything related to COM interop in it).

Why am I getting this error and how can I have a class inherit two
interfaces with only one enabled for COM interop.

Thanks a lot,

Skip.

Nov 16 '05 #2
John,

Your solution seems to have solved my problem, thanks. Here's the
definition of my second interface if anyone ever reads this thread in the
future:

[ComVisible(false)]
public interface IB
{
bool UpdateInformation();
}
Skip.

"John Puopolo" wrote:
Skip:

I've not tried this, but perhaps you can use the ComVisible attribute to
specifically hide the IB interface from COM interop? It appears from a
quick look at the doc that you can apply ComVisible fairly granularly.

Anyone else have thoughts on this?

John


Nov 16 '05 #3

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

Similar topics

2
by: Ken Fine | last post by:
(originally posted to one of macromedia's groups; no help, so hopefully someone here can help me out. I'm using VBScript ASP.) When designing administrative interfaces to websites, we often need...
21
by: Franco Gustavo | last post by:
Hi, Please help me to understand this, because I don't see what I'm missing. I was reading a lot of examples on Internet that explain that C# doesn't implement multiple inheritance it...
6
by: rakefet | last post by:
Hi. I'm really new to this world of .Net so your help would be most appreciated... We have API and COM interfaces developed in c. We would also like to supply a .net interface to our clients....
11
by: JJ | last post by:
Can someone explain to me how interfaces are such a big help in creating objects? I was under the impression that an Interface was a template for an Object, just sort of a class with only method ...
17
by: Picho | last post by:
Hi all, I popped up this question a while ago, and I thought it was worth checking again now... (maybe something has changed or something will change). I read this book about component...
5
by: Michael McCarthy | last post by:
I want to develop plugin support for a system.montitor module I am working on. A lot of the modules will do mostly interop stuff for an older system, but I want to use it myself as well to monitor...
0
by: P Reddy | last post by:
Hi All, Greetings!!! I have a question. Please respond.... I am trying to write a C# component that need to inherit some of the the interfaces from unmanged code(VC). I think one way to...
3
by: pratham | last post by:
Hi, I was seeing code of PetShop 2.0 and find is quite .. differnet design and architecture .. too much of clutter in classes .. order class using and Iorder and Iorder using an orderInfo and...
22
by: RSH | last post by:
Hi, I have been reading on interfaces working on samples I've run across on the web. For the life of me I cannot seem to grasp them. It appears to me that interfaces are simply blueprints to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.