現在のコードが存在するアセンブリのパスを取得する方法はありますか?呼び出し元のアセンブリのパスは必要ありません。コードを含むパスだけが必要です。
基本的に、私の単体テストは、dllに関連して配置されているいくつかのxmlテストファイルを読み取る必要があります。テストdllがTestDriven.NET、MbUnit GUI、またはその他のものから実行されているかどうかに関係なく、パスが常に正しく解決されるようにしたい。
編集:人々は私が求めていることを誤解しているようです。
私のテストライブラリは次の場所にあります
C:\ projects \ myapplication \ daotests \ bin \ Debug \ daotests.dll
そして私はこの道を取得したいと思います:
C:\ projects \ myapplication \ daotests \ bin \ Debug \
MbUnit Guiから実行すると、これまでの3つの提案は失敗します。
Environment.CurrentDirectory
c:\ Program Files\MbUnit を与えますSystem.Reflection.Assembly.GetAssembly(typeof(DaoTests)).Location
C:\ Documents and Settings \ george \ Local Settings \ Temp \ ....\DaoTests.dllを提供し ますSystem.Reflection.Assembly.GetExecutingAssembly().Location
前と同じになります。