Home

LINQPad Not Allowing Use of WebView2

Hello,

I find LINQPad to be an invaluable tool. I've been using for many versions. One of the things I do with LINQPad is create minimal prototypes that we eventually turn into "enterprise code" that goes into our automated build/deploy processes.

A current prototype I have uses WebView2 to load a JavaScript library to do some processing and validation. Unfortunately, with LINQPad 8, this no longer works. This worked in version 7, but now breaks:

async Task Main()
{
    await new WebView2().EnsureCoreWebView2Async(null);
}

Resulting Error:

Is there something I need to do to continue using WebView2 in LINQPad 8?

Thanks!

Comments

  • This might be related to whether you're running LINQPad from a custom folder or from an installed location in ProgramFiles. I suspect that WebView2 is trying to create a data folder where LINQPad.Runtime.dll is located. If this is under ProgramFiles, it will fail.

    Try specifying a known writable location for your data folder. Note that you will run into the same issue in a production application, once it's installed to ProgramFiles.

    Alternatively, use LINQPad's defaults:

    var env = await CoreWebView2Environment.CreateAsync (
        Util.BrowserEngine.GetWebView2ExecutableFolder (),
        Util.BrowserEngine.GetWebView2DataFolder ());
    

    Using Util.BrowserEngine.GetWebView2ExecutableFolder ensures that your code will work even if the WebView2 runtime is not installed.

Sign In or Register to comment.