C#:每类在我的COM DLL Regasm生成注册表项? [英] C#: Regasm generating registry entries for every class in my COM DLL?
问题描述
我写在C#中的类库(IE浏览器BHO),目前与大体积的东西,我认为是垃圾输出REGASM的生成注册表项来了闹得不可开交。
I'm writing a class-library (IE BHO) in C# and currently wrangling with the large volume of what I think is junk output coming from REGASM's generated registry keys.
短版是这样的:我只是想揭露少数类(现:一类)IE浏览器(和COM的其余部分)。只有一个类有ClassInterfaceAttribute和GUID的东西设置,我可以测试该附加只需要此类的COM注册表项 - 然而,REGASM产生的GUID和注册表项,每类在整个项目
The short version is this: I only want to expose a handful of classes (currently: ONE class) to IE (and the rest of COM). Only one class has the ClassInterfaceAttribute and GUID stuff set, and I can test that the add-on only requires the COM registry keys for this class -- and yet, REGASM generates GUIDs and registry keys for every class in the entire project.
这是恼人的,有点不安,因为我不希望我的类名坐在用户的注册表,除非他们绝对的有无的在那里。
This is annoying and somewhat disturbing as I do not want my class names sitting in users' registry unless they absolutely have to be there.
要说句公道话,其中许多其他类都因为我使用它们在驱动程序的应用程序从另一个项目在同一个解决方案为公用,来解决IE的调试黑洞......
To be fair, many of those other classes are marked public because I use them in a driver app from another project in the same solution, to work around IE's debugging black hole...
我还是很绿色COM一般(特别是与.NET),我想知道什么是隐藏我的所有其他的类regasm最好的方法是什么?或者,至少,为什么这些类 - 即使它们被标记为公共 - 都出现了,当我还没有设置任何的COM标志他们
I'm still very green to COM in general (especially relating to .Net) and I was wondering what is the best way to hide all my other classes from regasm? Or, at least, why these classes that -- even though they are marked public -- are showing up when I haven't set any of the COM flags for them?
谢谢!
推荐答案
使用内部
访问修饰符的东西,并不需要有公开
修改。对于东西,确实需要公开
访问使用标记有ComVisible特性的属性来部分隐藏起来。
Use internal
access modifier for stuff that doesn't need to have public
modifier. For stuff that really needs public
access use ComVisible attribute to partially hide it.
例如:
[ComVisible(false)]
public class ClassToHide {
//whatever
};
public class ClassToExpose {
public void MethodToExpose() {}
[ComVisible(false)]
public void MethodToHide() {}
};
所有公共类的所有公共成员函数和成员变量是COM可见默认情况下。所以首先想到使其内部和如果你真的从COM与标记有ComVisible特性需要他们公开其隐藏起来。
All public member functions and member variables of all public classes are COM-visible by default. So first think of making them internal and if you really need them public hide them from COM with ComVisible.
这篇关于C#:每类在我的COM DLL Regasm生成注册表项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!