C# mvvm灯继电器命令未触发
我有一个使用Mvvm Light和Ninject的wpf应用程序。在我的本地机器上,RelayCommand工作正常,当我将应用程序移动到另一台服务器时,它不再调用该方法,消息框不会弹出 在MainViewModel.cs中,我有C# mvvm灯继电器命令未触发,c#,ninject,mvvm-light,C#,Ninject,Mvvm Light,我有一个使用Mvvm Light和Ninject的wpf应用程序。在我的本地机器上,RelayCommand工作正常,当我将应用程序移动到另一台服务器时,它不再调用该方法,消息框不会弹出 在MainViewModel.cs中,我有 public ICommand GoClickCommand { get { return new RelayCommand(() => MessageBox.Show("Directly in property!"), () =
public ICommand GoClickCommand
{
get
{
return new RelayCommand(() => MessageBox.Show("Directly in property!"), () => true);
}
}
在MainWindow.xaml中,我有
`<Button Content="Go" HorizontalAlignment="Left" Margin="508,54,0,0" VerticalAlignment="Top" Width="75"
Command="{Binding GoClickCommand}" IsDefault="True" Click="btn_go_Click"/>`
我删除了对Ninject的所有引用,问题就消失了,如果有人好奇,我可以把我的项目发给他们。
//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;
}
}