Edit: I've discovered that the Setup file was not generating the App.deps.json file and App.dll.config file.
- Without the first, the AccountManagement was not found.
- Without the .dll.config file - the app was not reading the config contents.
I have a WPF application, that uses the System.DirectoryServices.AccountManagement to access Active Directory.
When I build the app either in Debug or Release configuration - all is working just fine.
However, when I create a Setup Project, then there's an exception thrown:
It might be worth mentioning that it was previously a .NET5 app, which was upgraded to .NET6 using the Microsoft upgrader.
Here is the Project properties:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<ApplicationIcon>Assets\rfid.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<None Remove="Assets\logo-white.png" />
<None Remove="Assets\logo.png" />
<None Remove="Assets\user.svg" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MyCompany.DutScanner" Version="5.2.1" />
<PackageReference Include="MyCompany.TestSystemLogger" Version="1.2.1" />
<PackageReference Include="LoadingSpinner.WPF" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2-beta1" />
<PackageReference Include="Serilog" Version="2.11.0" />
<PackageReference Include="Serilog.AspNetCore" Version="6.0.1" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.336902">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
<PackageReference Include="System.DirectoryServices.AccountManagement" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\logo-white.png" />
<Resource Include="Assets\logo.png" />
<Resource Include="Assets\user.svg" />
</ItemGroup>
<ItemGroup>
<None Update="App.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\PublishProfiles\" />
</ItemGroup>
<ItemGroup>
<None Include="..\.editorconfig" Link=".editorconfig" />
</ItemGroup>
</Project>
Yet, an exception is thrown whenever an attempt to make connection to the ActiveDirectory is made:
Exception: System.DirectoryServices.AccountManagement is not supported on this platform
Frameworks installed on the machine:
- dotnet-sdk-6.0.301-win-x64.exe
- aspnetcore-runtime-6.0.8-win-x64.exe
- dotnet-hosting-6.0.8-win.exe
- windowsdesktop-runtime-6.0.8-win-x64.exe
- ndp48-web.exe (.NET Framework 4.8)
Machine: Windows 10, x64
What I have attempted so far:
- removing and re-adding the package from NuGet package manager
- adding the .dll from the debug/release folders manually to the setup project.
- verified the right version is used in the App.deps.json
the App.deps.json file contents:
Please help! :/