WPF application using CEFSharp Web Browser crashing in clickonce release
Asked Answered
S

2

6

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.

Xaml Error when creating an instance of the UserControl

> <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; }
    }
}
Sparker answered 30/11, 2015 at 12:44 Comment(0)
S
8

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

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.

Sinuation answered 1/12, 2015 at 8:33 Comment(0)
G
-4

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.

Greysun answered 30/11, 2015 at 13:21 Comment(1)
That would be better served as a comment, in addition, it is not the problem he is describing. From his question it seems like the project runs fine in Visual Studio but crashes when it is installed through click once.Mor

© 2022 - 2024 — McMap. All rights reserved.