?
Solved

Making dataset instances invisible to COM

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

650 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