我设法在 Delphi win32 应用程序中托管 CLR 2.0,该应用程序能够在 Delphi 控件中创建和托管 WPF 控件,类似于 WinForms 应用程序的 ElementHost。
现在,我想将我的解决方案移至 CLR 4.0 并且一切正常,除非我尝试创建具有关联 Xaml 资源的 UserControl。在这种情况下,它会导致堆栈溢出错误,从而强制进程退出!但是,如果我通过代码(不阅读 xaml)创建一些 WPF 控件,那么一切正常!
我设法进入了框架代码,直到我进入了XamlReader.LoadBaml方法,该方法在执行以下代码后就崩溃了:
// We don't actually use the GeneratedInternalTypeHelper any more.
// But for v3 compat, don't allow loading of internals in PT unless there is one.
Type internalTypeHelper = null;
if (streamInfo.Assembly != null)
{
try
{
internalTypeHelper = XamlTypeMapper.GetInternalTypeHelperTypeFromAssembly(parserContext);
}
// This can perform attribute reflection which will fail if the assembly has unresolvable
// attributes. If that happens, just assume there is no helper.
catch (Exception e)
{
if (MS.Internal.CriticalExceptions.IsCriticalException(e))
{
throw;
}
}
}
请注意,加载的程序集也使用 CLR4。
谢谢你的帮助,
摩根