How to setup Chromium Embedded for Visual Studio? - chromium-embedded

I'm a newbie to CEF and am wanting to build the "cefsimple" example in Visual Studio but I can't find any .sln file. how does someone setup the development environment?

In order to use the Chromium Embedded Framework you must make your own solution .sln file. You can use CMake to do it.
I would recommend the GUI version if you aren't familiar with it. Just point CMake to the project directory (Cef) and generate a solution file. You should get ALL_BUILD, CefClient, CefSimple, LibCef_Wrapper and ZeroCheck projects when you open the Cef Source.

I used Nuget to get the packages:
I then set up a control like so (I'm using WPF):
<UserControl x:Class="WebpageViewer"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:cefSharp="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="300">
<Grid>
<cefSharp:ChromiumWebBrowser Address="www.google.com" />
</Grid>
</UserControl>
And made sure to call Cef.Initialize() before InitializeComponent in the constructor for the control:
Cef.Initialize(New CefSettings())

Related

WPF with Dynamic module loading using prism

This is about WPF project with Dynamic module loading and navigation using prism. I am trying to figure out - how the WPF project loads shell module so that all related files such as Bootstrapper, catalog, etc. are initialized to register the modules (WPF projects) through catalog. This is required so we can use prism module loader.
More details below -
We are migrating a Silverlight project to a WPF project.
Silverlight Solution has following projects
MyProject.Web (aspx) with default.aspx which is initializing shell module ("I believe") by following code
<param name="source" value="ClientBin/ShellModule.xap" />
ShellModule Silverlight project with catalog.xaml which registers all Modularity:ModuleInfo and Bootstrapper.cs inheriting UnityBootstrapper which returns IModuleCatalog
Other Silverlight Module projects
I am trying to figure out how would WPF project achieve it without the MyProject.Web project and without a default.aspx
My very odd random guess - from App.xaml of Root project somehow?
WPF - https://prismlibrary.github.io/docs/wpf/legacy/Modules.html
Silverlight - https://www.wintellect.com/dynamic-module-loading-with-silverlight-navigation-using-prism/

Microsoft Interactions is not recognized in XAML

My goal:
I want to use Interaction Triggers in that way:
<i:Interaction.Triggers>
Therefore I opened the Nuget and installed this:
After this the two references (Microsoft.Expression.Interactions and System.Windows.Interactivity) were added to my project. The path of those points to the package directory (Blend.Interactivity.Wpf.1.0.1340.0) in my project folder.
The problem:
The namespace is not recognized by Visual Studio. I tried:
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
Intelisense is not recognizing any elements inside the i-Tag.
The .Net version of the project is 4.5.2.
I tried to remove and reinstall the package.
Any ideas what went wrong here?

How to reference dll from another project?

How do I reference the FontAwesome.WPF dll from the OtherProject in the Test project.
In the OtherProject I reference it like this:
xmlns:fa="http://schemas.fontawesome.io/icons/"
I know how to reference the project itself:
xmlns:fa="clr-namespace:OtherProject;assembly=OtherProject"
But I think the namespace should change, however I don't know to what and where to find it?
This is the FontAwesome.WPF in the object browser:
I don't know how the first reference would relate to this or might help me or if this is even possible?
So what I want is calling this:
<fa:ImageAwesome Icon="Flag" VerticalAlignment="Center" HorizontalAlignment="Center" />
Without installing the NuGet package in the Test project.
You should read the following accepted answer.
MSBuild doesn't copy references (DLL files) if using project dependencies in solution
In short, you have two options:
Install the NuGet package in the test project as well.
Add some code (not only XAML markup) in the OtherProject that references a type in the FontAwesome assembly.
Then the assembly should be copied to the test project's output directory.

How to get WPF XAML Designer to play nicely with IValidatableObject from NET Standard 2.0 libraries?

Background:
using Visual Studio 2017 v15.4 (no ReSharper or any weird extensions)
Repro solution includes 2 projects:
WPF project: .NET 4.6.1, using NuGet PackageReference format
Class library: NET Standard 2.0
Both projects have the System.ComponentModel.Annotations NuGet package installed.
Problem
After upgrading my WPF project's NuGet format from the old packages.config to the new PackageReference, I started experiencing design-time errors:
Or sometimes the harsher flavor:
To start with, the following ViewModel code works fine:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
public class MainWindowViewModel
{
public ValClass MyProp => new ValClass();
}
public class ValClass : IValidatableObject
{
//Implementation stuff
}
However, if I then define an identical class in my NET Standard project, and include that as a type in my ViewModel, it produces the error.
Comparing an F12 on the IValidatableObject of these 2 classes:
The WPF version:
#region Assembly System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.1\System.ComponentModel.DataAnnotations.dll
#endregion
The NET Standard 2.0 version:
#region Assembly System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// C:\Users\a0110\.nuget\packages\system.componentmodel.annotations\4.4.0\ref\netstandard2.0\System.ComponentModel.Annotations.dll
#endregion
It's clear that the same type and namespace are defined in assemblies with different names--not just assembly versions.
How can I get the XAML Designer to successfully locate whatever assembly is required to use IValidatableObject?
Things I have Tried
Installing VS v15.5 preview and targeting the WPF project to .NET 4.7 (also 15.5 preview 2 and 3, .NET 4.7.1)
Adding the old System.ComponentModel.DataAnnotations reference to the WPF project (with and without the NuGet version)
reverting back to packages.config format (this didn't actually succeed; it appears that I'm stuck with PackageReference!)
grabbing a copy of the System.ComponentModel.Annotations.dll from the project's output folder and referencing it directly (VS would not let me do this)
adding a bindingRedirect to my App.config
adding <DependsOnNETStandard>True</DependsOnNETStandard> to the .csproj
adding <DependsOnNETStandard>netstandard2.0</DependsOnNETStandard> to .csproj
adding <_HasReferenceToSystemRuntime>true</_HasReferenceToSystemRuntime> to .csproj
adding the NETStandard.Library NuGet package to the WPF project
Update
For anyone else who is plagued by this issue, I have found a workaround:
Locate the System.ComponentModel.Annotations.dll on your hard drive that your NET Standard project uses for IValidatableObject. Copy it to a location within your project.
Uninstall the System.ComponentModel.Annotations NuGet package from your solution
Give your NET Standard project a direct reference to DLL you copied
Give your WPF project a reference to the standard assembly System.ComponentModel.DataAnnotations
Upgrade your WPF project to target .NET 4.7.1
Compile. Your WPF design-time should be free from this error.
.

MahApps.Metro Errors appear after initial install

I've just installed the MahApps from GitHub
https://github.com/MahApps/MahApps.Metro
I'm getting errors immediately. In MainWindow.xaml the following line is underlined
d:DataContext="{d:DesignInstance MetroDemo:MainWindowViewModel}
And there are several error messages, such as:
The name "MainWindowViewModel" does not exist in the namespace "cld-namespace:MetroDemo".
The name "ButtonsExample" does not exist in the namespace "clr-namespace:MetroDemo.ExampleViews".
The project does run, but I'm unable to inspect any of the design.
Has anyone experienced this and managed to resolve?
Turns out this was to do with Parallels on my Mac.
Issue found here, with resolution from Mick MacCallum.
The issue with the namespaces was due to VS using network share to access the files on my Mac file system.
I copied the entire project over to the absolute path on the virtual machine and the problem was solved.
The project now builds/runs correctly but I can also inspect the design.

Resources