In my WPF C# application, I have included an executable file (.EXE) into the project, and set its build action to “Resource”. Then, I have dragged the file from the solution explorer into the Resources.resx file under “Properties”.
However, when I trigger the following code, it displays 0, because there this.Resources contains 0 elements. How come? What exactly am I doing wrong here?
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
namespace Application
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : System.Windows.Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
MessageBox.Show(this.Resources.Count + "");
}
}
}
The
Application.Resourcesare completely disconnected from the resources you can add to your project. Those resources can be accessed viaApplicationAssemblyNameHere.Properties.Resources.