Проекты Desktop Bridge автоматически не устанавливают текущий каталог в выходную папку вашего проекта ... вместо этого они используют каталог по умолчанию Windows.
Чтобы исправить это в вашем проекте, в главной точке запуска (App.xaml.cs
), просто добавьте следующее ...
public partial class App : Application
{
public App()
{
SetCurrentDirectory();
}
/// <summary>
/// Sets the current directory to the app's output directory. This is needed for Desktop Bridge, which
/// defaults to the Windows directory.
/// </summary>
private void SetCurrentDirectory()
{
// Gets the location of the EXE, including the EXE name
var exePath = typeof(App).Assembly.Location;
var outputDir = Path.GetDirectoryName(exePath);
Directory.SetCurrentDirectory(outputDir);
}
}