0

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

1
  • Which version are you using?
    – Flores
    Sep 25, 2018 at 18:31

1 Answer 1

1

'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.InvokeAsync<string>(
                "exampleJsFunctions.showPrompt",
                message);
        }
    }
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.