question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] NullReferenceException is thrown when creating new context

See original GitHub issue

Context:

  • Playwright Version: 1.35
  • Operating System: Windows 10
  • .NET version: .NET 4.8.1 (Net Standard 2.0)
  • Browser: Chromium
  • Extra: I ran the reproducible test from inside my own program so I am sure it uses the same DLLs etc.
using System.Threading.Tasks;
using Microsoft.Playwright;

    public static void TestReproduce()
    {
        var playwright = Playwright.CreateAsync().Result;
        var browser = playwright.Chromium.LaunchAsync().Result;
        var context= browser.NewContextAsync().Result; // <==== NullReferenceException thrown
    }

Describe the bug

Reliably reproducible when running my program (which includes this function) from inside Visual Studio 2022 with debugging.

NullReferenceException is thrown when creating new context at the following stack trace, on a thread-pool thread: stacktrace

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
slang25commented, Jun 15, 2023

I had this during a previous version upgrade, bit of a long shot but have you tried deleting th obj & bin directories? It can come from a difference in the newer .NET playwright assembly and the cached javascript files, and a mismatch of versions.

1reaction
Constante-ou-Mortcommented, Jun 15, 2023

Hi , have you tried GetAweiter().GetResult()?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I fix the error: System.NullReferenceException
A NullReferenceException exception is thrown when you try to access a member on a type whose value is null. A NullReferenceException exception ...
Read more >
Object Reference Not Set to an Instance of an Object
This infamous and dreaded error message happens when you get a NullReferenceException. This exception is thrown when you try to access a member—for...
Read more >
What is NullReferenceException in C#? - Code Maze
In C#, a NullReferenceException occurs when we try to access a variable whose value has not been set or has been set to...
Read more >
Object reference not set to an instance of an object” error?
The “Object reference not set to an instance of an object” is a very famous error in C# that appears when you get...
Read more >
OnModelCreating null reference exception with inverted ...
When creating the context model a null reference error is thrown with the entity setup below. The issue was first detected in a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found