Solved

Making dataset instances invisible to COM

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 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