问题
I have a simple WPF application which works fine in debug but when i do a clickonce release its crashing when trying to load the CEFSharp web browser
I have a login page where the user then clicks open browser once clicked i get the following error
An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: The invocation of the constructor on type 'MyProject.Views.CefSharpWebBrowserUserControl' that matches the specified binding constraints threw an exception.
> <TabItem Header="Web Page" Name="CefWebPage">
> <Grid Background="#FFE5E5E5" Margin="0">
> <Grid.ColumnDefinitions>
> <ColumnDefinition Width="871*"/>
> </Grid.ColumnDefinitions>
> <views:CefSharpWebBrowserUserControl x:Name="CefSharpWebBrowserUserControl"></views:CefSharpWebBrowserUserControl>
> </Grid>
> </TabItem>
Exception: Cannot create an instance of "CefSharpWebBrowserUserControl".
TargetInvocationException: Exceptionhas been thrown by the target of an invocation.
FileNotFoundException: Could not load file or assembly 'CefSharp.Core, Version=45.0.0.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138' or one of its dependencies. The system cannot find the file specified.
code behind
public partial class CefSharpWebBrowserUserControl : UserControl
{
public CefSharpWebBrowserUserControl()
{
InitializeComponent();
var settings = new CefSettings();
settings.PackLoadingDisabled = true;
WebBrowser = new ChromiumWebBrowser();
WebBrowser.Address = "www.google.com";
BrowserGrid.Children.Add(WebBrowser);
}
public ChromiumWebBrowser WebBrowser { get; set; }
}
}
回答1:
ClickOnce
by default doesn't include the unamanged
resources that CefSharp
requires. There are many issues that already address this topic.
Here are a couple of useful ones
- https://github.com/cefsharp/CefSharp/issues/1314
- Deploying WPF Application with 3rd Party DLLs
Searching the GitHub
project is always an excellent resource.
https://github.com/cefsharp/CefSharp/search?q=clickonce&type=Issues&utf8=%E2%9C%93
You also need to make sure VC++ Redist
is installed on your target machines. See https://github.com/cefsharp/CefSharp#version-branches for more info one which VC++
version you require.
In general, please try searching GitHub
/StackOverflow
before posting your question.
回答2:
Would you mind trying to add the https:// at the WebBrowser.Address?
So from:
WebBrowser.Address = "www.google.com";
To have:
WebBrowser.Address = "https://www.google.com";
This post might also help you.
来源:https://stackoverflow.com/questions/33998981/wpf-application-using-cefsharp-web-browser-crashing-in-clickonce-release