?
Solved

Making dataset instances invisible to COM

Posted on 2006-06-20
2
Medium Priority
?
246 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Screencast - Getting to Know the Pipeline
Suggested Courses

809 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