Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF application using CEFSharp Web Browser crashing in clickonce release

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; }
    }
}
like image 481
McCann46 Avatar asked Nov 30 '15 12:11

McCann46


1 Answers

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.

like image 117
amaitland Avatar answered Oct 19 '22 03:10

amaitland