Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generics and COM interop

Status
Not open for further replies.

mmilan

Programmer
Jan 22, 2002
839
GB
Hi everyone,

I have a Class Library assembly written in VB2005, which I wish to expose via COM to an application written in Visual Basic 6. The library acts as an object store, and basically wraps a Hash table that is used for passing variables around DOTNET assemblies and, if my boss gets his way, VB6.

This is one of those personal projects that my boss has decided he likes the look of...

Anyway, here's the problem. To enable the user to add and inspect variables in the object store, I use a couple of generic methods -
Code:
GetObj(of T)(obj as T, sKey as String)
SetObj(of T)(obj as T, sKey as String)

Having marked the library for InterOp and also marked the Class as being exposed to COM, I'm finding it no-longer compiles as VB2005 knows that COM is going to freak at the generic methods. Fair enough...

At the moment, I have exposed the class via the <Microsoft.VisualBasic.ComClass()> attribute.

What I would like to do is to mark the generic methods so as they are ignored by the InterOp, allowing the compilation of the library to succeed - at which point I'll add things like VB6GetInt, VB6GetString etc to support VB6's needs (there will only be a few datatypes that VB6 should care about...)

Does anyone have an idea how this might be achieved?

Thanks,

mmilan.

 
Sorted it...

I used the <ComVisible(False)> attribute on the generic methods to deny them to COM.

Only just starting to play with InterOp.

mmilan.
 
Marking the methods protected would mean that only objects derived from the object store would be able to use these functions...

Thanks for your time though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top