我正在为我的WinForms应用程序构建一组WPF控件,以便最终将整个项目转换为WPF。我正在使用WinForms ElementHost模块,并在其中设置我的WPF控件。
这里是我的问题,我已经通过ElementHost在WinForms应用程序上托管了大量的WPF控件。然而,当我遇到这个控件时,它告诉我:
这里是我的问题,我已经通过ElementHost在WinForms应用程序上托管了大量的WPF控件。然而,当我遇到这个控件时,它告诉我:
Error setting value'Assembly.MyCustomControl' to property 'Child'. Details:
Could not load type 'Assembly.MyCustomControl' from assembly 'Assembly'......
我以同样的方式将其他控件加载到该项目中,没有任何问题。库中托管控件的代码也没有错误。我现在感到非常困惑。
在尝试将ElementHost设置为控件后,此错误还会显示在WinForms设计器上。
at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at System.UnitySerializationHolder.GetRealObject(StreamingContext context)
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializePropertyAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement, CodePropertyReferenceExpression propertyReferenceEx, Boolean reportError)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeAssignStatement(IDesignerSerializationManager manager, CodeAssignStatement statement)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.DeserializeStatement(IDesignerSerializationManager manager, CodeStatement statement)
编辑
我稍后会将此作为答案发布,但重新启动Visual Studio解决了问题...