Windows App SDK を組み込んだアプリケーションを実行すると、「Unable to load DLL 'Microsoft.Internal.FrameworkUdk.dll' or one of its dependencies」 エラーが発生する
Windows App SDK を組み込んだアプリケーションを実行すると、
System.DllNotFoundException例外が発生し、「Unable to load DLL 'Microsoft.Internal.FrameworkUdk.dll' or one of its dependencies」
のエラーが発生する現象と対処法を紹介します。
現象の確認
Windows App SDK を組み込んだアプリケーションを実行すると、実行時に次のエラーが発生します
エラーメッセージ
System.DllNotFoundException
HResult=0x80131524
Message=Unable to load DLL 'Microsoft.Internal.FrameworkUdk.dll' or one of its dependencies:
指定されたモジュールが見つかりません。 (0x8007007E)
Source=Microsoft.InteractiveExperiences.Projection
対処法
Microsoft.Internal.FrameworkUdk.dllへの参照がないため、Microsoft.Internal.FrameworkUdk.dllを配置するか、
自己完結型のアプリケーションにします。
自己完結型のアプリケーションにする場合は、プロジェクトファイルに以下のXMLを追記します。
詳しくは
こちらの記事を参照してください。
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<WindowsPackageType>None</WindowsPackageType>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<Platforms>x86;x64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.4" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<Platforms>x86;x64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64</RuntimeIdentifiers>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
<WindowsPackageType>None</WindowsPackageType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.4" />
</ItemGroup>
</Project>
著者
iPentecのメインプログラマー
C#, ASP.NET の開発がメイン、少し前まではDelphiを愛用