I'm struggling with this. My WPF app, in debug/release works fine. After I publish it, via InstallShield Express, I get a runtime exception and the program crashes.
When the program crashes, I can choose to debug the program in Visual Studio, it breaks in the RelayCommand which looks like
public class RelayCommand : ICommand
{
public Action<object> _execute;
public RelayCommand(Action<object> execute)
{
this._execute = execute;
}
public bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
this._execute(parameter); // where the breakpoint is
}
}
The error message is
FileNotFoundException was unhandled
Could not load file or assembly 'TaskScheduler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified
I'm lost as to why this is. I have other commands on the page, and they are all set up in the following manner
public ICommand SaveScheduledTaskCommand { get; set; }
public ICommand OpenFileCommand { get; set; }
#region Constructor
public MyApp()
{
OpenFileCommand = new RelayCommand(new Action<object>(OpenFile)));
ScheduledTaskCommand = new RelayCommand(new Action<object>(SaveScheduledTask));
}
#endregion
private void OpenFile(object o)
{
MessageBox.Show("OF"); //works fine
}
private void SaveScheduledTask(object o)
{
MessageBox.Show("TS"); //never shows
TaskScheduler ts = new TaskScheulder();
//more code
}
I guess the issue is with the TaskScheduler.dll (based upon the error message) but, the .dll exists in the installed folder (under c:\Program Files\Compamy\MyApp)...
I don't think it matters but, the TaskScheduler.dll is saved outside of my project (it is saved on the desktop) but I assume this is not relevant as the installer will take a copy of it and save it to the program Files folder any way?
I used InstallShield Express to create the installer and other than this, it works fine. I also another 3rd party dll, XCeed, and this work fine in my app.
I'm totally lost as to what I can do as I can't see how I can fix the code! Why can't the application "see" the dll?