【发布时间】:2021-03-17 13:34:53
【问题描述】:
您好,我有 wpf 桌面应用程序。我正在使用 cefsharp.wpf 铬浏览器打开网页。我从 nuget pacakge manager(版本 87.1.132)添加了 cefsharp。它在我的系统(Windows 10、64 位操作系统)中运行良好。
但是当我在客户端环境(windows 2012 r2,64 位操作系统)中运行我的 exe 时,会发生奇怪的事情,即浏览器仅在我第一次尝试时才加载。基本上我有一个按钮和点击按钮我打开一个窗口,其中有cefsharp铬浏览器。因此,当窗口第一次打开时,浏览器不会加载任何内容。现在,如果我关闭窗口并再次打开它,浏览器将重定向到我的 url。只有第一次浏览器不加载。在第一次之后它每次都会加载,直到我关闭 exe 并重试。
如果我关闭 exe 并再次打开它并尝试打开该窗口,再次浏览器将不会加载任何内容。然后我关闭该窗口并重试浏览器将完美运行。
我所做的非常简单,我在一个窗口中的 xaml 文件中有浏览器,在加载窗口时在 cs 文件中我为浏览器分配一个地址,仅此而已。
在xml中
<cefSharp:ChromiumWebBrowser x:Name="browser" />
在加载的窗口上的 xaml.cs 中
browser.address = url; // 我正在使用www.xero.com 登录网址(我认为这并不重要,因为它确实可以第二次使用)。
谁能告诉我这里发生了什么?
我有 cefsharp 的 debug.log 文件,上面写着:
[0317/231700.441:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale
[0317/231700.442:ERROR:alloy_main_delegate.cc(539)] Could not load locale pak for en-US
[0317/231700.537:ERROR:viz_main_impl.cc(150)] Exiting GPU process due to errors during initialization
[0317/231700.542:ERROR:browser_gpu_channel_host_factory.cc(168)] Failed to launch GPU process.
[0317/232456.104:WARNING:resource_bundle.cc(1086)] locale resources are not loaded
[0317/232456.105:WARNING:resource_bundle.cc(1086)] locale resources are not loaded
[0317/232456.421:WARNING:resource_bundle.cc(431)] locale_file_path.empty() for locale
[0317/232456.422:ERROR:alloy_main_delegate.cc(539)] Could not load locale pak for en-US
[0317/232458.805:INFO:CONSOLE(333)] "Refused to connect to 'https://analytics.google.com/g/collect?v=2&tid=G-Q622B96ZEQ>m=2oe330&_p=609855886&sr=1366x768&_gaz=1&ul=en-us&cid=1821054078.1615983899&_s=1&dl=https%3A%2F%2Flogin.xero.com%2Fidentity%2Fuser%2Flogin%3FReturnUrl%3D%252Fidentity%252Fconnect%252Fauthorize%252Fcallback%253Fresponse_type%253Dcode%2526client_id%253DC35C4505FBEA4D31A8E5A0404FDA9E0E%2526redirect_uri%253Dhttp%25253A%25252F%25252Flocalhost%2526scope%253Dopenid%252520profile%252520email%252520files%252520accounting.transactions%252520accounting.tra...2520accounting.journals.read%252520accounting.settings%252520accounting.settings.read%252520accounting.contacts%252520accounting.contacts.read%252520accounting.attachments%252520accounting.attachments.read%252520offline_access%252520payroll.employees%252520payroll.employees.read%2526state%253D108Sydney%2526code_challenge%253D3b5GLmW09QQB-C4Sq8ud0M0sEYpqFr5_KY20way8l1U%2526code_challenge_method%253DS256&dt=Login%20%7C%20Xero%20Accounting%20Software&sid=1615983898&sct=1&seg=0&en=page_view&_fv=1&_nsi=1&_ss=1' because it violates the following Content Security Policy directive: "default-src 'self' https://browsercheck.xero.com https://edge.xero.com https://js-agent.newrelic.com https://bam.nr-data.net https://telemetry.ext.platformdevelopment.xero.com https://api.mixpanel.com https://www.googletagmanager.com https://www.facebook.com https://connect.facebook.net https://p.adsymptotic.com https://*.fls.doubleclick.net https://*.linkedin.com https://www.google-analytics.com https://identity.xero.com https://login.xero.com https://go.xero.com https://static.xero.com 'unsafe-inline'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.
", source: https://www.googletagmanager.com/gtag/js?id=G-Q622B96ZEQ&l=dataLayer&cx=c (333)
[0317/232458.806:INFO:CONSOLE(333)] "Refused to connect to 'https://stats.g.doubleclick.net/g/collect?v=2&tid=G-Q622B96ZEQ&cid=1821054078.1615983899>m=2oe330&aip=1' because it violates the following Content Security Policy directive: "default-src 'self' https://browsercheck.xero.com https://edge.xero.com https://js-agent.newrelic.com https://bam.nr-data.net https://telemetry.ext.platformdevelopment.xero.com https://api.mixpanel.com https://www.googletagmanager.com https://www.facebook.com https://connect.facebook.net https://p.adsymptotic.com https://*.fls.doubleclick.net https://*.linkedin.com https://www.google-analytics.com https://identity.xero.com https://login.xero.com https://go.xero.com https://static.xero.com 'unsafe-inline'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.
", source: https://www.googletagmanager.com/gtag/js?id=G-Q622B96ZEQ&l=dataLayer&cx=c (333)
[0317/232458.819:INFO:CONSOLE(0)] "Refused to load the image 'https://www.google.com.au/ads/ga-audiences?v=1&t=sr&slf_rd=1&_r=4&tid=G-Q622B96ZEQ&cid=1821054078.1615983899>m=2oe330&aip=1&z=174504349' because it violates the following Content Security Policy directive: "img-src 'self' https://browsercheck.xero.com https://edge.xero.com https://js-agent.newrelic.com https://bam.nr-data.net https://telemetry.ext.platformdevelopment.xero.com https://api.mixpanel.com https://www.googletagmanager.com https://www.facebook.com https://connect.facebook.net https://p.adsymptotic.com https://*.fls.doubleclick.net https://*.linkedin.com https://www.google-analytics.com https://identity.xero.com https://login.xero.com https://go.xero.com https://static.xero.com".
", source: https://login.xero.com/identity/user/login?...
我验证了区域设置文件夹,它与我的本地系统中的相同。它说拒绝连接,因为它违反了某些东西..然后当我第二次尝试时它不应该工作。所以我很困惑这里发生了什么。谁能告诉我这里出了什么问题?
帮助!
【问题讨论】:
-
您是否以编程方式设置了 tge 语言环境文件夹? en-us.pak 是否存在于 locales 文件夹中?这里没有太多信息,日志说它无法加载所需的 pak 文件。如果文件存在,那么我建议检查权限。如果它具有读取权限,那么我会使用docs.microsoft.com/en-us/sysinternals/downloads/procmon 来查看低级别发生的情况。
-
@amaitland 不,我没有以编程方式设置文件夹,但如果有任何问题,它第二次如何工作?
-
我从未见过或收到过类似报告,至少我记得。很难说。缺少语言环境会给你带来问题,所以我会先尝试修复它,看看你会得到什么。 CefSharp 只是众多 Chromium 嵌入式框架包装器之一,欢迎您在magpcss.org/ceforum/index.php 上提问以获得第二意见。
-
服务器是否运行 Citrix?
-
只有在需要提供自定义设置时才需要调用 Cef.Initialize。否则应调用以下内容github.com/cefsharp/CefSharp/blob/cefsharp/88/CefSharp.Wpf/… 因为我没有重现该问题的示例,所以我不知道您的情况发生了什么。如果手动调用 Cef.Initialize 可以解决问题,那么这是一个简单的解决方法