4

We are supporting an aging VB6 system that we have written new code for in .Net, put the code into assemblies and then exported *.tlb files for use with the VB6 codebase.

My question is, on every computer I wish to run the code on, do I have to use Regasm to register the type libraries?

I ask because it gets difficult to keep track of type library installations as computers break, new computers get added etc. Also, if we update the .Net code, we need to go around every computer and re-register the type library.

To sum up, is it possible to run .Net code from VB6 without having to register the type library on each computer the code is running on?

Thankyou

4

1 に答える 1

7

/tlb:filename.tlbRegasm.exe は、コマンド ライン オプションを指定して実行した場合にのみ、タイプ ライブラリを作成します。次に、プロジェクト + 参照を使用して VB6 プロジェクトで使用し、[参照] ボタンを使用して .tlb ファイルを選択します。Tlbexp.exe を実行して取得することもできますが、登録は必要ありません。IDE の [COM 相互運用機能に登録] オプションを使用することをお勧めします。ただし、レジストリを書き込むことができるように、昇格した VS を実行する必要があります。ショートカットを右クリックし、「管理者として実行」を選択します。

VB6 のリストに表示されるのは少し便利ですが、取得するのは困難です。Regasm.exe によって呼び出される標準の .NET 登録コードは、VB6 がコンポーネントをリストに自動的に追加するために必要な「プログラマブル」キーを書き込みません。不足しているキーを書き込む [ComRegisterFunction] 属性で装飾されたカスタム登録関数を作成する必要があります。[参照] をクリックするだけでよい場合は、その価値はありません。

また、ユーザーのマシンにタイプ ライブラリを登録する必要がないことにも注意してください。VB6 コンパイラでのみ必要です。[ComVisible] クラスを登録する必要があります。セットアップ プロジェクトを使用すると簡単です。DLL の Register プロパティを vsdrpCOM に設定するだけです。

于 2012-05-27T15:13:43.043 に答える