I have a wpf app using Mvvm Light and Ninject. On my local machine the RelayCommand works fine, when I move the app to another server it no longer calls the method (the message box does not pop up).
In MainViewModel.cs I have
public ICommand GoClickCommand
{
get
{
return new RelayCommand(() => MessageBox.Show("Directly in property!"), () => true);
}
}
In the MainWindow.xaml I have
`<Button Content="Go" HorizontalAlignment="Left" Margin="508,54,0,0" VerticalAlignment="Top" Width="75"
Command="{Binding GoClickCommand}" IsDefault="True" Click="btn_go_Click"/>`
I have a method in the code behind call btn_go_click that is called when the button is clicked, this is just to make sure that the button actually works. I'm not sure if it has something to do with Ninject. I'm trying to make the app self-contained (just one .exe file), so I have code in the App.xaml.cs file to resolve missing assemblies. I tried running the app without this code, and the only 2 assemblies that the app needs are the GalaSoft.MvvmLight.WPF.dll and Ninject.dll. I commented out the code and put these 2 assemblies in the same folder as the app and the RelayCommand still isn't firing. The code in the actual app is more complex, I changed the code in the GoClickCommand property to try to figure out what's wrong. Thanks for any help or advice.
//from http://www.paulrohde.com/merging-a-wpf-application-into-a-single-exe/
{
AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
App.Main();
}
private static Assembly OnResolveAssembly(object sender, ResolveEventArgs e)
{
var thisAssembly = Assembly.GetExecutingAssembly();
//Get the name of the AssemblyFile
var assemblyName = new AssemblyName(e.Name);
var dllName = assemblyName.Name + ".dll";
//Load from Embedded Resources - This function is not called if the Assembly is already
//in the same folder as the app.
var resources = thisAssembly.GetManifestResourceNames().Where(s => s.EndsWith(dllName));
var resourcesEnumerated = resources as string[] ?? resources.ToArray();
if (resourcesEnumerated.Any())
{
//99% of cases will only have one matching item, but if you don't,
//you will have to change the logic to handle those cases.
var resourceName = resourcesEnumerated.First();
using (var stream = thisAssembly.GetManifestResourceStream(resourceName))
{
if (stream == null) return null;
var block = new byte[stream.Length];
//Safely try to load the assembly
try
{
stream.Read(block, 0, block.Length);
return Assembly.Load(block);
}
catch (IOException ex)
{
MessageBox.Show(ex.Message);
}
catch (BadImageFormatException ex)
{
MessageBox.Show(ex.Message);
}
}
}
//in the case where the resource doesn't exist, return null.
return null;
}
}