大家下午好
我试图在c中升级我的GUI#通过使用webBrowser组件,但它不支持所有内容,并且文件没有显示为
所以我尝试使用ChromiumWebBrowser,这似乎是一个很好的解决方案
但当我编译这个项目时,它就退出了,没有任何错误
public ChromiumWebBrowser chromeBrowser;
public void InitializeChromium()
{
CefSettings settings = new CefSettings();
// Note that if you get an error or a white screen, you may be doing something wrong !
// Try to load a local file that you're sure that exists and give the complete path instead to test
// for example, replace page with a direct path instead :
// String page = @"C:UsersSDkCarlosDesktopafolderindex.html";
String page = string.Format(@"{0}html-resourceshtmlmainmenu.html", Application.StartupPath);
//String page = @"C:UsersSDkCarlosDesktopartyom-HOMEPAGEindex.html";
if (!File.Exists(page))
{
MessageBox.Show("Error The html file doesn't exists : " + page);
}
// Initialize cef with the provided settings
Cef.Initialize(settings);
// Create a browser component
chromeBrowser = new ChromiumWebBrowser(page);
// Add it to the form and fill it to the form window.
this.Controls.Add(chromeBrowser);
chromeBrowser.Dock = DockStyle.Fill;
// Allow the use of local resources in the browser
BrowserSettings browserSettings = new BrowserSettings();
browserSettings.FileAccessFromFileUrls = CefState.Enabled;
browserSettings.UniversalAccessFromFileUrls = CefState.Enabled;
chromeBrowser.BrowserSettings = browserSettings;
}
和这个
public void InitializeChromium()
{
CefSettings settings = new CefSettings();
Cef.Initialize(settings);
chromeBrowser = new ChromiumWebBrowser("http://stackoverflow.com/");
this.Controls.Add(chromeBrowser);
chromeBrowser.Dock = DockStyle.Fill;
}
并且在InitializeComponent 之后调用该函数
这是退出后显示的内容
The thread 'vshost.NotifyLoad' (0x7bc) has exited with code 0 (0x0).
The thread '<No Name>' (0x315c) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x1004) has exited with code 0 (0x0).
'cefTest.vshost.exe' (Managed (v4.0.30319)): Loaded 'c:usersdark_onedrivedocumentsvisual studio 2012ProjectscefTestcefTestbinx64DebugcefTest.exe', Symbols loaded.
'cefTest.vshost.exe' (Managed (v4.0.30319)): Loaded 'c:usersdark_onedrivedocumentsvisual studio 2012ProjectscefTestcefTestbinx64DebugCefSharp.Core.dll'
'cefTest.vshost.exe' (Managed (v4.0.30319)): Loaded 'c:usersdark_onedrivedocumentsvisual studio 2012ProjectscefTestcefTestbinx64DebugCefSharp.WinForms.dll'
'cefTest.vshost.exe' (Managed (v4.0.30319)): Loaded 'c:usersdark_onedrivedocumentsvisual studio 2012ProjectscefTestcefTestbinx64DebugCefSharp.dll'
The program '[8200] cefTest.vshost.exe: Managed (v4.0.30319)' has exited with code -2147483645 (0x80000003).
希望有人能帮助
确保您使用的是相同的.Net FrameWork(4.5.2)或更多