0

我设法在 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。

谢谢你的帮助,

摩根

4

1 回答 1

0

我发现这个问题要归功于 Stackoveflow 上的另一篇文章(在 Delphi 中使用/不使用 JCL 托管 CLR - 示例参见重要说明)。

我不得不用 Set8087CW($133F) 初始化 fpu,然后奇怪的 stackoverlow 停止了!

我仍然有一个奇怪的行为:没有任何调试器一切都很好,但是如果我从 VS2010 运行应用程序,则会显示一个黑色的 wpf 表单,阻止我与内容交互。但是,如果我运行应用程序然后附加调试器,那么一切都很好!

于 2010-07-20T03:06:57.267 回答