Exception happened when WindowManager.ShowWindow()
FaustPipeDream opened this issue · comments
I'm using WindowManager.ShowWindow to show a new window,It work fine at first,but today it not work with the Exception ArgumentException: Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type
and SystemWindows.Markup.XamlParseException: can't create "VerifyFunc" from text
.
Hrer is the code :
public class RootViewModel : Conductor<IScreen>.Collection.OneActive
{
private readonly IWindowManager WindowManager;
private readonly ViewModelFactory ViewModelFactory;
private TerminalViewModel TerminalViewModel { get; set; }
public RootViewModel(ViewModelFactory viewModelFactory, IWindowManager windowManager){
ViewModelFactory = viewModelFactory;
TerminalViewModel = viewModelFactory.CreateTerminalViewModel();
WindowManager = windowManager;
}
public void DoShowTerminalControl()
{
//Exception happened in here
WindowManager.ShowWindow(ViewModelFactory.
CreateTerminalControlViewModel(TerminalViewModel.TerminalTreeNodes));
}
}
It work fine at first and i'm sure I didn't modify it recently.
Can you please provide enough information for me to reproduce the issue (at the very least, the XAML for your RootView), and the full stack trace of the two exceptions, please?
In RootView XAML,I just define a Button and bind the DoShowTerminalControl()
to it.
And here is the stack trace of SystemWindows.Markup.XamlParseException: can't create "VerifyFunc" from text
At System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
At System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
At System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
At System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
At TerminalPlus.Views.Terminal.TerminalControlView.InitializeComponent()
At D:\WorkShop\Code\TerminalPlus\Views\Terminal\TerminalControlView.xaml : first line
Here is the stack trace of ArgumentException: Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type``
At System.Delegate.CreateDelegate(Type type, Object target, String method, Boolean ignoreCase, Boolean throwOnBindFailure)
At System.Delegate.CreateDelegate(Type type, Object target, String method)
At System.Xaml.Schema.SafeReflectionInvoker.CreateDelegateCritical(Type delegateType, Object target, String methodName)
At System.Xaml.Schema.SafeReflectionInvoker.CreateDelegate(Type delegateType, Object target, String methodName)
At System.Xaml.EventConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
At MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateObjectWithTypeConverter(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value)
At MS.Internal.Xaml.Runtime.ClrObjectRuntime.CreateFromValue(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value, XamlMember property)
At MS.Internal.Xaml.Runtime.PartialTrustTolerantRuntime.CreateFromValue(ServiceProviderContext serviceContext, XamlValueConverter`1 ts, Object value, XamlMember property)
At System.Xaml.XamlObjectWriter.Logic_CreateFromValue(ObjectWriterContext ctx, XamlValueConverter`1 typeConverter, Object value, XamlMember property, String targetName, IAddLineInfo lineInfo)
I create the TerminalControlViewModel
in the factory and share the TreeNodes of the TerminalViewModel
with TerminalControlViewModel
.
This looks like it's a problem in your XAML. I can't help unless you post your XAML. Notice how neither of the stack traces mention Stylet, just the XAML loader.
Thank you,I just found I add some verify function in the XAML but forgot bind method to them. What a silly problem
Glad you solved it!