呈现Silverlight网站时WebView崩溃 [英] WebView crashes when rendering silverlight site

查看:68
本文介绍了呈现Silverlight网站时WebView崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从嵌入在MonoMac应用程序中的浏览器访问silverlight 5应用程序.对于浏览器,我正在使用MonoMac.WebKit.WebView 尝试访问任何Silverlight应用程序时

I need to access a silverlight 5 application from a browser embedded in a MonoMac application. For the browser I am using MonoMac.WebKit.WebView When trying to access any silverlight application for instance

webView.MainFrame.LoadRequest(新的NSUrlRequest(新的NSUrl("http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/")));

webView.MainFrame.LoadRequest(new NSUrlRequest (new NSUrl ("http://samples.msdn.microsoft.com/Silverlight/SampleBrowser/")));

我收到以下错误 http://pastebin.com/s8PDfDyq .我在XCode中对本机WebView进行了尝试,并且可以正确加载,因此我相信是影响它的单桥.

I get the following error http://pastebin.com/s8PDfDyq. I tried the same with the native WebView in XCode and it loads correctly so I believe is the mono bridge that is affecting it.

除了WebView之外,还有其他替代方法可将浏览器嵌入到Mono OSX应用程序中吗?

Is there any other alternative for embedding a browser in a Mono OSX application besides WebView ?

谢谢, 克劳迪奥

推荐答案

经过大量的网络搜索并尝试了不同的方法之后,我得以在最新的MonoDevelop中使这些方法正常工作.实际上,这里有两个独立的问题.在我的测试中,第一个会影响OSX 10.6和更高版本(无法访问10.5).第二个影响OSX 10.7和更高版本.

After lots of web searches and trying different things, I was able to get things working in the latest MonoDevelop. There are actually two separate issues here. The first affects OSX 10.6 and later in my testing (no access to 10.5). The second affects OSX 10.7 and later.

  1. 即使在OSX 10.6中,许多Silverlight网站也会在webView中崩溃.您可以通过更改useragent来解决崩溃问题

  1. Many silverlight websites will crash in a webView even in OSX 10.6. You can fix the crash by changing the useragent as so

webBrowser.CustomUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2";

很难相信这可以解决问题,但是即使没有的用户代理字符串非常相似,也可以做到这一点:

It is hard to believe that this fixed things, but it did, even though the useragent string without this is very similar:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.57.2 (KHTML, like Gecko)

  • 即使有此修复程序,OSX 10.7或更高版本上的最新MonoDevelop webView + Silverlight也会崩溃.为什么?似乎silverlight插件在10.7和更高版本中的堆执行安全性方面存在问题. MonoDevelop 2.8.8.4并未在unix可执行文件上设置该标志来阻止堆执行,但最新的MonoDevelop设置了该标志.从MonoDevelop,我不知道您是否可以到达将传递给ld的参数更改为-allow_heap_execute的地方.但是您可以使用十六进制编辑器自己在应用程序的unix可执行文件中修改该标志...

  • Even with this fix, the latest MonoDevelop webView + Silverlight on OSX 10.7 or later = crash. Why? It appears that the silverlight plugin has issues with the heap execution security stuff in 10.7 and later. MonoDevelop 2.8.8.4 did not set the flag on the unix executable to prevent heap execution, but the latest MonoDevelop does. From MonoDevelop, I don't know if you can get to a place where you change the parameters passed to ld to do -allow_heap_execute. But you can modify the flag yourself in the unix executable in the appbundle with a hex editor...

    我抓到 HexFiend ,然后将其放在我的应用程序文件夹中.显示输出应用程序捆绑包的内容(通过右键单击),然后深入Contents/MacOS/.那里只有一个文件.在HexFiend中打开它.您将看到这样的字节:

    I grabbed HexFiend and then put it in my applications folder. Show the contents of your output app bundle (via right click) and then dig into Contents/MacOS/ . There will be one file there. Open it in HexFiend. You will see bytes like this:

    CEFAEDFE 07000000 03000000 02000000 13000000 3C080000 85002001
    

    看到最后1个?那是没有堆执行标志.通过将1更改为0可以将其关闭.这使我的webView能够显示运行Silverlight的页面而不会在OSX 10.8上顺利运行

    See that last 1? That is the no heap execution flag. Turn it off by changing the 1 to a 0. This got my webView that shows pages with Silverlight to run without a hitch on OSX 10.8

    我最终写了一个小单声道控制台应用程序,我称之为后构建步骤来为我完成此任务.它被调用为

    I ended up writing a little mono console app that I call as a post build step to do this for me. It is invoked as

    mono "<path-to-console-app-exe>" "<path-to-mac.app-package>"
    

    这是主要功能:

    public static void Main (string[] args)
    {
        if (args.Length > 0)
        {
            if (Directory.Exists(args[0]))
            {
                string containingFolder = Path.Combine (Path.Combine(args[0], "Contents"), "MacOS");
                var files = Directory.GetFiles (containingFolder);
                if (files.Length == 1)
                {
                    var bytes = File.ReadAllBytes(files[0]);
                    byte one = (byte)1;
                    byte allButOne = (byte)~one;
                    bytes[27] = (byte)(bytes[27] & allButOne); 
                    File.WriteAllBytes(files[0], bytes);
                    return;
                }
            }
        }
        throw new InvalidOperationException("Failed to allow heap execution");
    }
    

  • 就其价值而言,Mac上的Silverlight似乎是一个非常脆弱的主张.我真的没有短期选择,您也许也没有,但是弄清楚这一点,使我获得了各种搜索结果,这些搜索结果涉及到Silverlight和OSX的更新版本有各种问题的人.

    For what it's worth, Silverlight on Mac seems to be a very brittle proposition. I don't really have a short-term choice about it, and you may not either, but figuring this out led me through all kinds of search results of people having various problems with Silverlight and updated versions of OSX.

    以下是帮助我解答问题的链接:

    Here are the links that helped me along to my answers:

    Firefox崩溃,并且Silverlight和同一堆栈在考虑修复的情况下关闭了堆保护功能

    链接的Firefox崩溃,其中通过在执行堆执行的进程外运行silverlight插件解决了问题允许

    Apple资源标记在标头

    实际上列出了堆标志的铬错误执行一个-而不是在苹果的文档中-太棒了!

    在Connect上提交的Bug 1关于通过更改用户代理字符串而修复的崩溃

    错误2在Connect上提交了有关通过更改用户代理字符串修复的崩溃的信息

    这篇关于呈现Silverlight网站时WebView崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆