Windows XP Embedded系でのASP.NET利用時のセットアップ

Windows XP Embedded(新しいブランド名ではWindows Embedded Standard)や、それをベースにしたWEPOS、POS Ready等で、ASP.NETを使ってWeb Serviceを実装する時の注意点を説明します。

この記事は、Embedded特有というわけではなく、XPでIISやASP.NETを使う場合全般に当てはまるのですが、まとまった日本語の説明がないのと、組込み向けの製品としてはまだまだXPベースのOSはサポートが続くので、ここで紹介しておきますね。

 まず、症状ですが、APS.NETでWebサービス(*.asmxを使用)を作成しデバッグが一通り終わり、IISの本来のWebサイトに配置した際、以下の様なエラーメッセージが出ることがあります。そんな時は、この記事に書かれている対処方法を試してみてください。

Server Error in 'ServiceDir' Application.

Failed to access IIS metabase.

Description: An unhandled exception occurred durling the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Hosting.HostingEnvironmentException: Failed to access IIS metabase.

The process account used to run ASP.NET must have read access to the IIS metabase (e.g. IIS://servername/W3SVC). For more information on modifying metabase permissions, please see https://support.microsoft.com/?kbid=267904.

この現象は、ASP.NETのバージョンや、IISのセットアップ、Visual Studioのインストールの順番などによって、正しくASP.NETが使うユーザーのアクセス権が正しく設定されていなことによって引き起こされています。ASP.NETのIISセットアップを再構築すればこの現象は解決できます。

対応方法は、以下のとおりです。

  1. 管理者権限で、コマンドプロンプトを起動する
  2. \Windows\Microsoft.NET\Framework\v2.0.50727に移動する
  3. 次のコマンドを実行して、一旦全てのASP.NETのバージョンを削除する
    > aspnet_regiis.exe -ua
  4. 次のコマンドを実行して、ASP.NETをインストールする。
    > aspnet_regiis.exe -i
  5. 次のコマンドを実行して、ASPNETユーザーのアクセス権を設定する
    > aspnet_regiis.exe -ga MachineName \ASPNET
    MachineNameは、IISを動かしているPC、Serverの名前

以上で、ASMXファイルを実行することができるはずです。