?
Solved

Making dataset instances invisible to COM

Posted on 2006-06-20
2
Medium Priority
?
239 Views
Last Modified: 2008-03-10
Hi There,

I've got a C# assembly that's marked for COM Interop Registration.  It contans a dataset definition (.xsd file in the Visual Studio IDE).  When I look at the TLB file generated for the assembly, there's a bunch of objects from the dataset included.  (for example, if the dataset is called AlphaDS, there's a default interface generated for the dataset called _AlphaDS, and a coclass entry for AlphaDS, plus default objects for the tables, rows and events defined in the dataset)

I'd like to mark the Dataset as COMVisible(false) so it doesn't show up in the TLB.  I could mark the generated .cs file for the dataset with this attribute, but this file is auto-generated and the changes are lost each time I re-build the assembly.  

Anyone have any ideas?

Thanks
0
Comment
Question by:afuchigami
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:afuchigami
ID: 16967709
After some research and discussion on different forums, we figured out a solution.  Here's what we found for anyone who runs into this issue.

In VS2005, DataSet objects are marked as partial classes.  You could define another partial class for each Dataset object and mark it as COMVisible(false).  When the code is compiled, the completed Dataset object would get the COMVisible(false) attribute setting.

In VS2003 (and later), you can mark an entire assembly as not being visible to COM with the following attribute:  [assembly:ComVisible(false)]
When you do this, you have to explicitly mark all the classes/interfaces that you want visible to COM as COMVisible(true).  This is different from the default behaviour where each public object is visible to COM when this assembly attribute was not set.  Using this method, all the dataset objects are invisible to COM.

A different option would be to move all the datasets into a separate assembly that isn't used for COM Interop.

Note - the 'Register for COM Interop' option in Visual Studio isn't an assembly property - it's a post-build action performed by the Visual Studio IDE.

Thanks

0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 16979198
Closed, 500 points refunded.
PashaMod
Community Support Moderator
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question