tomaskrupka / Gripper

A web-scraping toolbox for .NET.
https://tomaskrupka.github.io/Gripper
MIT License
0 stars 0 forks source link

Compile error: Line Suppression State Error CS0246 The type or namespace name 'Log' could not be found #20

Open kiinoo opened 2 years ago

kiinoo commented 2 years ago

Hello,

I tried to use the lib via nuget, but failed to find webclient assembly (search result it empty :-(

so i tried to build from source via visual studio 2022, but got the following compile error:

Severity    Code    Description Project File    Line    Suppression State Error CS0246  
The type or namespace name 'Log' could not be found (are you missing a using directive or an assembly reference?)   Gripper.ChromeDevTools  c:\a\src\Gripper.ChromeDevTools\ChromeSession_Domains.cs    29  Active

any solutions?

thanks very much!

tomaskrupka commented 2 years ago

Hi, thanks for raising the issue.

I see that the Log namespace directory is missing from the repo. I'll try to fix that today.

However, builds for both Gripper.WebClient and Gripper.WebClient.Cdtr are on Nuget.

https://www.nuget.org/packages/Gripper.WebClient/0.6.1-alpha https://www.nuget.org/packages/Gripper.WebClient.Cdtr/0.0.10-alpha

Note that they are still alpha. Did you make sure to tick the 'include prerelease' box in the VS Nuget package manager when you were searching for them?

Screenshot 2022-06-04 141250
kiinoo commented 2 years ago

thanks for quick answers,

I found the webclient then :)

but no luck to make the example code run:

    using Gripper.WebClient;
    using Gripper.WebClient.Extensions;
    using Microsoft.Extensions.DependencyInjection;

    try
    {
            var serviceProvider = new ServiceCollection()
            .AddGripper() // Register all services + default settings.
            .AddLogging()
            .BuildServiceProvider();

            var webClient = serviceProvider.GetRequiredService<IWebClient>(); // Fresh window driver.

            var cts = new CancellationTokenSource(TimeSpan.FromSeconds(30));

            await webClient.NavigateAsync(
                    "https://tomaskrupka.github.io/Gripper/about",
                    PollSettings.FrameDetectionDefault,
                    cts.Token);

            var linksCountResponse = await webClient.MainContext.ExecuteScriptAsync(
                    "document.querySelectorAll('a').length",
                    cts.Token);

            Console.WriteLine($"Found {linksCountResponse.Result.Value} hyperlinks.");
    }
    catch (AggregateException ex)
    {
            foreach (var exception in ex.InnerExceptions)
            {
                    Console.WriteLine(exception.ToString());
            }
    }

it stucked at var webClient = serviceProvider.GetRequiredService<IWebClient>(); // Fresh window driver.

with an exception:

    Object reference not set to an instance of an object.
            at Gripper.ChromeDevTools.ChromeSession.<SendCommand>d__20.MoveNext()
            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
            at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
            at Gripper.ChromeDevTools.ChromeSession.<SendCommand>d__19`2.MoveNext()
            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
            at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
            at Gripper.ChromeDevTools.Network.NetworkAdapter.<Enable>d__15.MoveNext()
            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
            at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
            at Gripper.WebClient.CdpAdapter.<SubscribeToRdpEventsAsync>d__5.MoveNext()
            at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
            at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
            at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
            at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
            at Gripper.WebClient.CdpAdapter.<BindAsync>d__13.MoveNext()

File list in my compile target folder:

    ConsoleApp2.deps.json
    ConsoleApp2.dll
    ConsoleApp2.exe
    ConsoleApp2.pdb
    ConsoleApp2.runtimeconfig.json
    Gripper.ChromeDevTools.dll
    Gripper.WebClient.dll
    GripperProfile_Default
    Microsoft.Extensions.Configuration.Abstractions.dll
    Microsoft.Extensions.Configuration.dll
    Microsoft.Extensions.DependencyInjection.Abstractions.dll
    Microsoft.Extensions.DependencyInjection.dll
    Microsoft.Extensions.Logging.Abstractions.dll
    Microsoft.Extensions.Logging.dll
    Microsoft.Extensions.Options.dll
    Microsoft.Extensions.Primitives.dll
    Newtonsoft.Json.dll
    SuperSocket.ClientEngine.dll
    WebSocket4Net.dll