Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Quick Start For MS .Net 4.x

Alex Maitland edited this pageAug 2, 2023 ·6 revisions

For those targeting MS .Net 4.6.x, .Net 4.7.x and .Net 4.8

Starting inM115.Net 4.6.2 is the minimum supported version.

1.0 Install Nuget Packages

Install one of the following via theNuget Package Manager from within Visual Studio

  • CefSharp.WinForms
  • CefSharp.Wpf
  • CefSharp.OffScreen

2.0 AnyCPU (Optional)

  • When targetingAnyCPU withPrefer32bit = true then no further action is required. Your application is32bit and will include the32bit binaries/resources.
  • When targetingAnyCPU please seehttps://github.com/cefsharp/CefSharp/issues/1714. TheMinimalExample demosAnyCPU support and can be used as a reference.

3.0 Read the Docs

  • Review thePost Installation steps in theReadme.txt file that's opened inVisual Studio upon installation.
  • Review theRelease Notes for the version you just installed, a list ofKnown Issues for the problems we're currently aware of.
  • Check out theAPI Doc, it's version specific, make sure you pick the correct version.

4.0 Add app.manifest to your application

Add anapp.manifest to your exe if you don't already have one, it's required for Windows 10/11 compatibility, GPU Acceleration, HighDPI support and tooltips. Seehttps://learn.microsoft.com/en-us/windows/win32/w8cookbook/windows-version-check#declaring-windows-10-compatibility-with-an-app-manifest

<!-- example.exe.manifest--><?xml version="1.0" encoding="UTF-8" standalone="yes"?><assemblymanifestVersion="1.0"xmlns="urn:schemas-microsoft-com:asm.v1"xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">    <assemblyIdentitytype="win32"name="Contoso.ExampleApplication.ExampleBinary"version="1.2.3.4"processorArchitecture="x86"    />    <description>Contoso Example Application</description>    <compatibilityxmlns="urn:schemas-microsoft-com:compatibility.v1">        <application><!-- Windows 10/11-->            <supportedOSId="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/><!-- * ADD THIS LINE *-->        </application>    </compatibility></assembly>

Thehttps://github.com/cefsharp/CefSharp.MinimalExample project contains an example app.manifest file in the root of the WPF/WinForms/OffScreen examples.

5.0 Add ChromiumWebBrowser to your application.

ImplementationExample
WPF For WPF use CefSharp.Wpf.ChromiumWebBrowser
<!-- Add a xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" attribute to your parent control--><!-- Create a new instance in code or in `xaml`--><Border Grid.Row="1"BorderBrush="Gray"BorderThickness="0,1">    <wpf:ChromiumWebBrowserx:Name="Browser"Address="www.google.com"/></Border>
WinForms For WinForms use CefSharp.WinForms.ChromiumWebBrowser
usingCefSharp;usingCefSharp.WinForms;//Create a new instance in code or add via the designervarbrowser=newChromiumWebBrowser("www.google.com");parent.Controls.Add(browser);//Load a different urlbrowser.LoadUrl("https://github.com");
OffScreen For OffScreen use CefSharp.OffScreen.ChromiumWebBrowser
usingCefSharp;usingCefSharp.OffScreen;//Create a new instance in codevarbrowser=newChromiumWebBrowser("www.google.com");//Load a different urlbrowser.LoadUrl("https://github.com");

5.1 Execute some JavaScript (optional)

// Add usage statement to access additional functionality// e.g. EvaluateScriptAsyncusingCefSharp;varresponse=awaitbrowser.EvaluateScriptAsync("1 + 1");if(response.Success){varresult=response.Result;}

Anyone with a GitHub account can edit this wiki, contributions are encouraged and welcomed.

Clone this wiki locally


[8]ページ先頭

©2009-2025 Movatter.jp