ComRegisterFunctionAttribute クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<ComVisibleAttribute(True)> _ <AttributeUsageAttribute(AttributeTargets.Method, Inherited:=False)> _ Public NotInheritable Class ComRegisterFunctionAttribute Inherits Attribute
[ComVisibleAttribute(true)] [AttributeUsageAttribute(AttributeTargets.Method, Inherited=false)] public sealed class ComRegisterFunctionAttribute : Attribute
[ComVisibleAttribute(true)] [AttributeUsageAttribute(AttributeTargets::Method, Inherited=false)] public ref class ComRegisterFunctionAttribute sealed : public Attribute

ComRegisterFunctionAttribute を使用すると、COM クライアントの要件に対応するための任意の登録コードを追加できます。たとえば、Microsoft.Win32 名前空間の登録関数を使用してレジストリを更新できます。登録メソッドを提供する場合は、その登録メソッドで実行された操作を元に戻すための登録解除メソッドにも System.Runtime.InteropServices.ComUnregisterFunctionAttribute を適用する必要があります。
格納しているアセンブリが アセンブリ登録ツール (Regasm.exe) や RegistrationServices.RegisterAssembly API メソッドを使用して (直接的または間接的に) 登録される場合、共通言語ランタイムはこの属性を持つメソッドを呼び出します。この属性を持つメソッドの参照可能範囲 (パブリック、プライベートなど) は任意ですが、このメソッドは static である必要があり、登録する型を表す Type パラメータを 1 つ受け取る必要があります。

適切なシグネチャを持つメソッドに ComRegisterFunctionAttribute と ComUnregisterFunctionAttribute を適用する方法を次の例に示します。
Imports System Imports System.Runtime.InteropServices Public Class MyClassThatNeedsToRegister <ComRegisterFunctionAttribute()> Public Shared Sub _ RegisterFunction(t As Type) 'Insert code here. End Sub <ComUnregisterFunctionAttribute()> Public Shared Sub _ UnregisterFunction(t As Type) 'Insert code here. End Sub End Class
using System; using System.Runtime.InteropServices; public class MyClassThatNeedsToRegister { [ComRegisterFunctionAttribute] public static void RegisterFunction(Type t) { //Insert code here. } [ComUnregisterFunctionAttribute] public static void UnregisterFunction(Type t) { //Insert code here. } }
using namespace System; using namespace System::Runtime::InteropServices; public ref class MyClassThatNeedsToRegister { public: [ComRegisterFunctionAttribute] static void RegisterFunction( Type^ t ) { //Insert code here. } [ComUnregisterFunctionAttribute] static void UnregisterFunction( Type^ t ) { //Insert code here. } };
import System.*; import System.Runtime.InteropServices.*; public class MyClassThatNeedsToRegister { /** @attribute ComRegisterFunctionAttribute() */ public static void RegisterFunction(Type t) { //Insert code here. } //RegisterFunction /** @attribute ComUnregisterFunctionAttribute() */ public static void UnregisterFunction(Type t) { //Insert code here. } //UnregisterFunction } //MyClassThatNeedsToRegister
import System; import System.Runtime.InteropServices; public class MyClassThatNeedsToRegister { ComRegisterFunctionAttribute public static function RegisterFunction(t : Type) : void { //Insert code here. } ComUnregisterFunctionAttribute public static function UnregisterFunction(t : Type) : void { //Insert code here. } }

System.Attribute
System.Runtime.InteropServices.ComRegisterFunctionAttribute


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- ComRegisterFunctionAttribute クラスのページへのリンク