PnP-Sites-Core icon indicating copy to clipboard operation
PnP-Sites-Core copied to clipboard

Does not work with AngleSharp 0.12.1

Open TOPDHI opened this issue 5 years ago • 11 comments

Hi guys,

I have a ClientSidePages section that fails to work after upgrade of NuGet packages. Error is:

03/03 - ClientSidePages Failed to apply template: Could not load type 'AngleSharp.Parser.Html.HtmlParserOptions' from assembly 'AngleSharp, Version=0.12.1.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea'.

Anything I have to do or is it you ?

TOPDHI avatar Jul 15 '19 14:07 TOPDHI

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ghost avatar Sep 03 '19 14:09 ghost

We use version 0.9.9 in core...you an only upgrade to a high version of AngleSharp if either we handle it for core as well or if you define the needed assembly redirects in the config files of your project

jansenbe avatar Sep 06 '19 06:09 jansenbe

I am also having a related issue to this.

I am running SharePointPnPCoreOnline 3.16.1912 With default dependant packages in this case AngleSharp 0.9.9

If I add the ClientSidePages section to my template I get an error saying that it cannot load AngleSharp 0.12.1.0

So, should I be using AngleSharp 0.12.1.0 or 0.9.9?

If I upgrade to 0.12.1.0 from 0.9.9 I get the same error that TOPDHI does.

What am I missing here?

See error stack trace below

01/08 - Initializing engine
02/08 - Features
03/08 - Application Lifecycle Management
04/08 - ClientSidePages
System.IO.FileLoadException: Could not load file or assembly 'AngleSharp, Version=0.12.1.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'AngleSharp, Version=0.12.1.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea' ---> System.IO.FileLoadException: Could not load file or assembly 'AngleSharp, Version=0.9.9.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'AngleSharp, Version=0.9.9.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea'

=== Pre-bind state information ===
LOG: DisplayName = AngleSharp, Version=0.9.9.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea
 (Fully-specified)
LOG: Appbase = file:///C:/Source/....Provisioning.Console/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : OfficeDevPnP.Core, Version=3.16.1912.0, Culture=neutral, PublicKeyToken=5e633289e95c321a.
===

Pete

pvranich avatar Dec 12 '19 00:12 pvranich

Pete,

I had the same issue after updating and than going back to the previous version. It updates some config entries and some dependencies. There will be better solutions i think but for me this worked:

-> Remove the entry from your App.config file -> Remove the version folders from your projects packages location (Optional i think) -> Uninstall pnpcoreonline (nuget) -> Uninstall Anglesharp(nuget)

-> install pnpcoreonline

Kind regards Simon

SimSpfx avatar Jan 13 '20 17:01 SimSpfx

@PaoloPia @jansenbe is the version 0.9.9 still one used by PnP Sites Core? I inherited a project that uses 0.13.0 and throws an error asking for 0.9.9 - I am just not sure if it is safe to donwgrade it (this is for SP2019)

panjkov avatar Sep 16 '20 14:09 panjkov

It looks like there was some major surgery carried out by the AngleSharp guys back in 2016, they decided to rename AngleSharp.Parser.Html. to AngleSharp.Html.Parser and various other breaking changes.

So it's highly unlikely you'll be able to use a more recent version in your project until PnP Sites Core is updated.

netclectic avatar Nov 26 '20 15:11 netclectic

@pvranich Did you find any solution , i am having same issue

image

DesireTusharG avatar Jan 06 '21 13:01 DesireTusharG

As I said above, it was renamed from AngleSharp.Parser.Html to AngleSharp.Html.Parser - if you want to use it with AngleSharp 14 you'll need to make sure you are using the latest version from nuget, it was updated a few weeks ago.

@pvranich Did you find any solution , i am having same issue

netclectic avatar Jan 06 '21 16:01 netclectic

@netclectic If i am using latest pnp package than "modern team site create" code is not working

image

Thats why i downgrade pnp version , but in lower version i have Angle sharp error.

This is deadlock kind of thing for me

DesireTusharG avatar Jan 07 '21 12:01 DesireTusharG

Hi @DesireTusharG,

I did upgrade my version but as you have found you also have to update the modern team site creation code.

Note: I was creating a unified group but the principal is the same.

This will require the relevant app registration setup in Azure AD. Here is a link for the different options on how to do that. Granting access via Azure AD App-Only

Here is the code I used once I got the app registration configured. This will give you a MS Graph authentication token.

protected virtual async Task<string> AquireAccessToken()
{
    IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
                                    .Create(<App registration app\client id>)
                                    .WithTenantId(<your tenant id>)
                                    .WithCertificate(<a valid certifacte to authenticate to the app registration>)
                                    .Build();
            AcquireTokenForClientParameterBuilder clientTokenBuilder = confidentialClientApplication.AcquireTokenForClient(new string[] { "https://graph.microsoft.com/.default" });
            AuthenticationResult authenticationResult = await clientTokenBuilder.ExecuteAsync();
            return authenticationResult.AccessToken;
}

Here is my code for creating the modern team site

string token = await AquireAccessToken();
if (!await Exists(Name))
{
    UnifiedGroupsUtility.CreateUnifiedGroup(
        DisplayName,
        Description,
        Name,
        token,
        OwnersArray,
        MembersArray,
        true,
        false
    );
}

pvranich avatar Jan 08 '21 02:01 pvranich

In this case i have different challenge that i am facing, i am working on cross tenant. where i don't have access of azure ad

DesireTusharG avatar Jan 08 '21 11:01 DesireTusharG