Blazor namespace Interop does not extist in the namespace

assembly-references blazor c# interop namespaces

Question

Where do I find the assembly reference and how can I add it?

Error Description:

CS0234 The type or namespace name 'Interop' does not exist in the namespace 'Microsoft.AspNetCore.Blazor.Browser' (are you missing an assembly reference?)

CS0103 The name 'RegisteredFunction' does not exist in the current context Phoneword.Client

I have a small Blazor project which I would like to run again after some time. But it seems I've deleteted the reference or something else is broken.

Edit I:

Blazor: 0.5.1

Target framework: .NET Standart 2.0

Popular Answer

'RegisteredFunction' does not exist anymore.

This is how you define a function in a JavaScript file:

window.exampleJsFunctions = {
  showPrompt: function (message) {
    return prompt(message, 'Type anything here');
  }
};

And this is how you call the function from your Blazor code:

using Microsoft.JSInterop;

    public class ExampleJsInterop
    {
        public static Task<string> Prompt(string message)
        {
            // Implemented in exampleJsInterop.js
            return JSRuntime.Current.InvokeAsync<string>(
                "exampleJsFunctions.showPrompt",
                message);
        }
    }



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why