スポンサーリンク

GACに存在するアセンブリのPDBをそのアセンブリのディレクトリに置く方法

Blog – Robert Bogue [MVP]

There are sometimes when your assembly almost has to be in the GAC and when you need to debug it.  This was difficult since if you registered a .NET assembly into the GAC the debugger wouldn’t break on it.  This is because the .PDB file information didn’t get loaded since it’s not in the same directory as the DLL.  Here’s how to work around that.

1) Install the Assembly in the GAC
2) Start-Run, %SYSTEMROOT%\Assembly\GAC
3) Navigate into the folder with name of the DLL that you want to debug
4) Navigate into the folder with the version number and public key that you want
5) Copy the .PDB file into this directory

うーん。やはりコード(VBS)でディレクトリ名を取得する方法はないか。手作業ねぇ。。。

まぁコピー先の最終的なディレクトリ名は事前にバージョンとパブリックキーのトークンがわかれば人間側で合成できなくもないのか。

ディレクトリ名:%SYSTEMROOT%\Assembly\GAC_MSIL\<アセンブリ名>\<バージョンナンバー>__<パブリックキートークン>

例::%SYSTEMROOT%\Assembly\GAC_MSIL\Foo\1.0.100.2000__xxxxxxxxxxxxxxxx
(間をつなぐアンダースコアは2個)

VSでそこにPDBが無くてもデバッグできる方法はわかります。でも常にプロセスにVSをアタッチできわけではありませんし、ログを出力している場合等でもスタックトレースに行番号出ると助かるじゃないですか(これが本題)。

gacutil.exeにPDBファイルも「いっしょに」コピーするオプションがあってもいい気がするなぁ。

しかし、バッチでインストーラーを作っているのがバレバレだな。

コメント

タイトルとURLをコピーしました