VB.NET を使用して、Visual Studio 2012 で .NET ユーザー コントロールの ActiveX コントロール ラッパーを作成しようとしています。
参考までに、これを Web ページに埋め込むことには興味がありません。VB6 アプリケーションで使用したいと考えています。
ここで概説されている手順に従いました
- クラス ライブラリを作成しました
- ユーザーコントロールを追加しました
- 「アセンブリCOMを可視化する」にチェックを入れます
「COM Interop に登録する」にチェックを入れます。
次に、com 登録を追加しました。私のユーザーコントロールクラスは次のようになります。
<ProgId("TestAx.DummyControl")> <ClassInterface(ClassInterfaceType.AutoDispatch)> Public Class DummyControl <ComRegisterFunction> Public Shared Sub RegisterClass(key As String) Dim sb As New StringBuilder(key) sb.Replace("HKEY_CLASSES_ROOT\", "") ' Open the CLSID\{guid} key for write access Dim k As RegistryKey = Registry.ClassesRoot.OpenSubKey(sb.ToString(), True) Dim ctrl As RegistryKey = k.CreateSubKey("Control") ctrl.Close() ' Next create the CodeBase entry - needed if not string named and GACced. Dim inprocServer32 As RegistryKey = k.OpenSubKey("InprocServer32", True) inprocServer32.SetValue("CodeBase", Assembly.GetExecutingAssembly().CodeBase) inprocServer32.Close() k.Close() End Sub <ComUnregisterFunction> Public Shared Sub UnregisterClass(key As String) Dim sb As StringBuilder = New StringBuilder(key) sb.Replace("HKEY_CLASSES_ROOT\", "") ' Open HKCR\CLSID\{guid} for write access Dim k As RegistryKey = Registry.ClassesRoot.OpenSubKey(sb.ToString(), True) ' Delete the 'Control' key, but don't throw an exception if it does not exist If k Is Nothing Then Return k.DeleteSubKey("Control", False) ' Next open up InprocServer32 Dim inprocServer32 As RegistryKey = k.OpenSubKey("InprocServer32", True) ' And delete the CodeBase key, again not throwing if missing inprocServer32.DeleteSubKey("CodeBase", False) ' Finally close the main key inprocServer32.Close() k.Close() End Sub End Class
Project>References
ツールボックスを右クリックして を選択すると、VB6 にアセンブリが表示されますComponents
。ここで tlb を参照しようとすると、「ファイル xxxx は ActiveX コンポーネントとして登録できませんでした」というエラー メッセージが表示されます。
私は何を逃したのですか?