Cefsharp chromium浏览器不仅在Windows Server 2012上首次加载



嗨,我有wpf桌面应用程序。我正在使用cefsharp.wpf铬浏览器打开网页。我从nugetpacakgemanager(版本87.1.132(中添加了cefsharp。它在我的系统(Windows10,64位操作系统(中运行得很好。

但当我在客户端环境(windows 2012 r2,64位操作系统(中运行exe时,奇怪的事情发生了,即浏览器并不是只有在我第一次尝试时才加载的。基本上我有一个按钮&点击按钮,我打开了一个窗口,里面有cefsharp chromium浏览器。所以当窗口第一次打开时,浏览器不会加载任何内容。现在,如果我关闭窗口并再次打开它,浏览器将重定向到我的url。只有第一次浏览器不加载。在第一次之后,它每次都会加载,直到我关闭exe并重试。

如果我关闭exe并再次打开它并尝试打开该窗口,浏览器将不会再次加载任何内容。然后我关闭那个窗口,再试一次,浏览器会完美工作。

我所做的很简单,我在一个窗口中的xaml文件中有浏览器,在加载窗口时的cs文件中,我为浏览器分配一个地址,就这样。

在xaml中<cefSharp:ChromiumWebBrowser x:Name="browser" />

在窗口加载上的xaml.cs中

browser.address = url;//我正在使用www.xero.com登录url(我认为这不重要,因为它第二次确实有效(。

有人能告诉我这里发生了什么事吗?

我有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&gtm=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&gtm=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&gtm=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?...

我验证了locale文件夹,它与本地系统中的文件夹相同。它说拒绝连接,因为它违反了一些东西。。那么当我第二次尝试时,它就不应该起作用了。所以我完全搞不清楚这里发生了什么。有人能告诉我这里出了什么问题吗?。

救命!

这是非常基本的。我没有初始化Cef。因为第二次没有它也能工作。当应用程序启动时,我确实在App.xaml.cs中初始化了它,现在它每次都能正常工作。尽管我仍然想知道为什么它能工作(如果我第二次加载窗口而没有初始化Cef(。

这是我补充的内容。

if (!Cef.IsInitialized)
{
try
{
//Perform dependency check to make sure all relevant resources are in our output directory.
Cef.Initialize(new CefSettings(), performDependencyCheck: true, browserProcessHandler: null);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
ErrorLogger.LogError(ex.GetType().ToString(), ex, GetType().FullName, System.Reflection.MethodBase.GetCurrentMethod().Name);
}
}

由于它在我的系统中运行得很好,没有初始化Cef,我认为这不是强制性的。但这似乎是必要的。

相关内容

最新更新