title: How to elegantly prevent a webservice proxy from being exposed to COM?
body: <p>I have a C# assembly that I use as an in-proc COM server consumed by an unmanaged C++ application. The assembly consumes a webservice that will not ever change so there's no need to ever update the webservice proxy classes. That's why the proxy classes are created once and <code>Reference.cs</code> files are simply put into the repository and only compiled from there.</p>
  
  <p>The problem is that by default the webservice proxy classes are public and are therefore exposed to COM. This inflates the typelib and pollutes registry. Changing visibility to internal break the assembly, so those entities need to remain public, but need not be exposed to COM.</p>
  
  <p>The dumb way is to approach every public interface/class in the <code>Reference.cs</code> files and mark it with</p>
  
  <pre><code>[System.Runtime.InteropServices.ComVisible(false)]
  </code></pre>
  
  <p>After that it is no longer exposed to COM.</p>
  
  <p>Is there a better way?</p>