【トラブル】【.NET】単体試験実行中に DirectoryNotFoundException が発生する

 ■ はじめに

単体試験実行中に 以下の「エラー内容」が発生した

■ エラー内容

System.IO.DirectoryNotFoundException: 
Could not find a part of the path
'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices\v4.0_14.0.0.0__b03f5f7f11d50a3a'.

https://github.com/axodox/AxoCover/issues/176

■ 発生環境

■ 対策案

  1. 指定されたフォルダパスを手作業で作成
  2. フォルダのアクセス権限をフルアクセスにする

詳細

System.IO.DirectoryNotFoundException で
「ディレクトリが見つからない」って言ってるので
指定されているパスを見たら、
「'C:\WINDOWS\Microsoft.Net\assembly\」までは存在しており
以降の「Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices\v4.0_14.0.0.0__b03f5f7f11d50a3a」
がなかった。
「Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices」と
「v4.0_14.0.0.0__b03f5f7f11d50a3a」を手作業でフォルダ作成した。

それで、実行したら今度は、UnauthorizedAccessException例外が発生した。
~~~~~~~
UnauthorizedAccessException
パス 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices\v4.0_14.0.0.0__b03f5f7f11d50a3a' へのアクセスが拒否されました
~~~~~~~

なので、フォルダ「v4.0_14.0.0.0__b03f5f7f11d50a3a」のアクセス権限を
フルアクセスにして、再度、単体試験を実行したら、うまくいった

関連記事

C#カバレッジツール / AxoCover ~ 初期設定編 ~

https://dk521123.hatenablog.com/entry/35768291

AxoCover に関するトラブルシューティング

https://dk521123.hatenablog.com/entry/37992731