473,387 Members | 1,673 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,387 software developers and data experts.

Interop issues

Hi,

I've written a C# dll and I'm trying to return a "List of structures" to my
C++ client application. I'm getting this warning while compiling my C# dll.

Warning 1 Type library exporter warning processing 'xyz'. Warning: Type
library exporter encountered a generic type instance in a signature. Generic
code may not be exported to COM.

Can someone guide me what needs to be done to resolve it?

Thanks,
Varun
May 21 '06 #1
1 2504
COM does not support generic interfaces and therefore you can not directly
expose a generic type. In my opinion you normally shouldn't expose a generic
type directly anyway. I always create a class that derives from the generic
collection to isolate my clients. If you take this route then you can also
implement a custom COM-visible interface that exposes the collection to COM
without impacting the .NET clients. If you explicitly implement the
interface then the .NET clients won't even see the COM-visible interface.
Finally note that ICollection itself is COM-visible so COM clients can use
that as well.

[ClassInterface(ClassInterfaceType.None)]
[ComVisible(true)]
[Guid(...)]
public class MyComCollection : Collection<myobject>, IMyComCollection
{
int IMyComCollection.Count
{
get { return this.Count; }
}

void IMyComCollection.Add ( myobject obj )
{
this.Add(obj);
}
,,,
}

[ComVisible(true)]
[Guid(...)]
public interface IMyComCollection
{
int Count { get; }
void Add ( myobject obj );
...
}

Note that I highly recommend that all COM visible objects get an explicit
GUID otherwise every time you recompile a new GUID is generated resulting in
registry bloat and causing interop problems. I also recommend that you set
your assembly to not be COM visible by default and that you explicitly mark
each object as visible as needed to avoid unnecessarily publishing objects as
COM visible that you didn't mean to. Finally make sure that you use the
ClassInterfaceAttribute on your COM classes to prevent .NET from
auto-generating an interface for you.

COM interfaces do not support inheritance so avoid using inheritance in
interface definitions for COM. Also note that the first COM visible
interface on a class is considered its default interface and that the
ordering in the code does not necessarily indicate the visibility for this
purpose. .NET 2.0 added a new COM attribute to explicitly identify the
default COM interface for this reason so use it if possible.

"Varun Bansal" wrote:
Hi,

I've written a C# dll and I'm trying to return a "List of structures" to my
C++ client application. I'm getting this warning while compiling my C# dll.

Warning 1 Type library exporter warning processing 'xyz'. Warning: Type
library exporter encountered a generic type instance in a signature. Generic
code may not be exported to COM.

Can someone guide me what needs to be done to resolve it?

Thanks,
Varun

May 21 '06 #2

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

Similar topics

17
by: Patrick | last post by:
I am almost certain that I could use HTTP Post/Get to submit XML Web Service call (over SSL as well, if using Version 3 of MSXML2) from an ASP Application? However, would I only be able to call...
8
by: Chango V. | last post by:
Hello, We seem to need a PIA for MSXML 4. According to the documentation, only the original publisher of a COM type library is supposed to create a .NET PIA. As far as I know, Microsoft hasn't...
1
by: Bob N5 | last post by:
I am working on an application that uses interop to do some simple operations with both Excel and Word. I have most of functionality working, but ran into issues on making things work with both...
0
by: Greg Bacon | last post by:
I have two C# projects: a production project and NUnit tests for it. I've recently added a test that causes a call into a registered COM component, and now the test fails with a TypeLoadException...
1
by: tcarvin | last post by:
If you are not in the mood for a rant, then leave now... I figure most VB.NET programmers have a VB6 background, so I hope you all don't mind the semi-VB.NET related Interop posting. Like most...
2
by: SiJP | last post by:
I've been having a few issues recently in creating a vb.net class library (using vs.net 2003), registering it for com interop and then invoking its functions from an object in VB6. The error I...
3
by: Brent | last post by:
I'm trying to open and manipulate an Excel spreadsheet from C#. To that end, I've referenced Interop.EXCEL9.dll, which I have on my machine. All of the examples I've read say to do something like...
5
by: Peter Ritchie [C# MVP] | last post by:
I've purposely been ignoring a CA2122 warning in some C++ interop code I've been working on for quite some time. I've just recently had the cycles to investigate the warning. The warning message...
5
by: muriwai | last post by:
Hi, I have a C# assembly project under Visual Stuio 2008 Pro on Windows Server 2008. I converted the project from VS 2005. The project references COM->Microsoft CDO for Windows 2000 Library...
1
by: Bhrionn | last post by:
Hello World, I am working on implementing a build for my companies application. The scenario implemeted is producing the error: ‘Class does not support automation or does not support expected...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
0
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...

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.