Solved

Making dataset instances invisible to COM

Posted on 2006-06-20
2
222 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
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now