In the following code, why do the methods Register and Unregister require a type parameter?
using System.Runtime.InteropServices;
namespace Foo {
[Guid("...")]
[ComVisible(true)]
public class Bar {
[ComRegisterFunction]
private static void Register (Type type) { ... }
[ComUnregisterFunction]
private static void Unregister(Type type) { ... }
}
}
I thought that perhaps it was because you only need one such function per assembly to register all of the types in that assembly, but that is not the case. No matter what I try (a class inheriting from Bar that is COM exportable, a subclass of Bar that is COM exportable, other unrelated classes that are COM exportable), the methods are only ever called once with (type == typeof(Bar)). I doubt the designers would require a useless parameter, so my question is, why is the type parameter required on these methods? Am I missing a case where the type parameter could differ from the class containing the method? Thanks,