wpf - WinForms ElementHost 错误

标签 wpf winforms elementhost

我正在 WinForms 应用程序一侧构建一组 WPF 控件,以便最终可以将整个项目转换为 WPF。我正在使用 WinForms ElementHost 模块并在其中设置我的 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 解决了问题...

最佳答案

您只需重新启动 Visual Studio。

关于wpf - WinForms ElementHost 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9875125/

相关文章:

c# - 当 showdialogwindow 阻止我尝试访问的窗口时,是否有事件或我可以使用的东西

.net - 哪些 .NET 组件使用 Dispatcher?

c# - 不能将超链接写成字符串

c# - 归并排序问题

WPF - 配置自定义事件以触发用户控件上的开始 Storyboard

c# - 如何让 CefSharp 使用 vs 公共(public)库中的配置 AnyCPU

c# - 验证规则

c# - 为什么 TimeSpan.TotalHours 计算不正确?

c# - 如何清除 ElementHost 控件的内存泄漏