Calling interface method in razor page throws unhandled exception

s.vinoth kumar

Unhandled exception rendering component:

Cannot provide a value for property _accountService on type Inventory_Management.Client.Pages.Authentication.Login. There are no registered service of type Inventory_Management.Shared.Services.AccountService.

AccountService.cs

  public interface IAccountService
    {
        Task<IResult> Login(Identity model);
    }
    public class AccountService : IAccountService
    {
        public async Task<IResult> Login(Identity model){}
    }

login.razor

@inject IAccountService _accountService;
<div></div>
@code{
private async Task Submit()
    {
        var result = await _accountService.Login(userlogin); // Unhandled exception
    }
}

Followed the Github sample, it doesn't have any scope in the startup class. https://github.com/iammukeshm/CleanArchitecture.WebApi.

References

Client-> Pages-> Authentication-> Login.razor.cs
Infrastructure-> Identity-> Authentication->IAuthenticationManager
Server-> Extensions -> ServiceCollectionExtension.cs
startup.cs -> services.AddServerLocalization();
Guru Stron

You need to have IAccountService (in the example you are trying to follow - see ServiceExtensions.AddIdentityInfrastructure and call to it in the Startup class) registered, for example with;

services.AddScoped<IAccountService, AccountService>(); // also you should register all AccountService's dependencies

and then resolve the interface, not the implementation:

@inject IAccountService _accountService;
<div></div>
@code{
private async Task Submit()
    {
        var result = await _accountService.Login(userlogin); // Unhandled exception
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Calling Java code from Flutter throws Unhandled Exception: MissingPluginException(No implementation found for method...)

From Dev

System throws Unhandled Exception

From Dev

Calling interface method in fragment throws ClassCastException

From Dev

Calling another page from Edit page throwing exception in Razor Pages

From Dev

Calling a UI method from Isolate listen method in Flutter throws exception

From Dev

While calling Post request via flutter DIO package It throws unhandled Exception Error

From Java

In JUnit, will @After method run, when @Test method throws an exception which is unhandled?

From Dev

Calling Dispose method inside constructor which throws an exception or behaves unexpectedly

From Dev

Calling a class method with scoped coroutine in Kotlin/Native on Linux throws exception

From Dev

Why Xamarin Forms tabbedpage throws unhandled exception when the child page is wrapped inside NavigationPage?

From Dev

C# throws Unhandled exception error

From Dev

Unhandled Exception: NoSuchMethodError: The method 'map' was called on null. Tried calling: map(Closure: (dynamic) => Reply)

From Dev

Unhandled Exception: NoSuchMethodError: The method '[]' was called on null. Tried calling: [] ("is_ordered"). check for null fields Firebase

From Dev

Javascript Exception : unhandled method size()

From Java

throws Exception in a method with Kotlin

From Dev

"Method must return a result" when calling another method that only throws an exception

From Dev

Calling asynchronous method of an interface

From Dev

Calling interface method of class

From Dev

Calling hidden interface method

From Dev

Artisan::call command package throws error exception will calling through web page

From Dev

Average of null list throws Exception on Razor View

From Dev

Calling dynamic callback function from an async method in the ScriptingObject of the BrowserControl throws Exception

From Dev

Calling a method and throws exception saying i'm passing in too many values... but i'm not

From Dev

Unhandled Exception: NoSuchMethodError: The method 'validate' was called on null

From Dev

Unhandled Exception: NoSuchMethodError: The method 'setString' was called on null

From Java

Java 8 method reference unhandled exception

From Android

Unhandled Exception: NoSuchMethodError: The method 'addUser' was called on null

From Dev

Unhandled Exception: NoSuchMethodError: The method 'toDate' was called on null

From Dev

Xamarin.Android: Async Task throws unhandled exception

Related Related

  1. 1

    Calling Java code from Flutter throws Unhandled Exception: MissingPluginException(No implementation found for method...)

  2. 2

    System throws Unhandled Exception

  3. 3

    Calling interface method in fragment throws ClassCastException

  4. 4

    Calling another page from Edit page throwing exception in Razor Pages

  5. 5

    Calling a UI method from Isolate listen method in Flutter throws exception

  6. 6

    While calling Post request via flutter DIO package It throws unhandled Exception Error

  7. 7

    In JUnit, will @After method run, when @Test method throws an exception which is unhandled?

  8. 8

    Calling Dispose method inside constructor which throws an exception or behaves unexpectedly

  9. 9

    Calling a class method with scoped coroutine in Kotlin/Native on Linux throws exception

  10. 10

    Why Xamarin Forms tabbedpage throws unhandled exception when the child page is wrapped inside NavigationPage?

  11. 11

    C# throws Unhandled exception error

  12. 12

    Unhandled Exception: NoSuchMethodError: The method 'map' was called on null. Tried calling: map(Closure: (dynamic) => Reply)

  13. 13

    Unhandled Exception: NoSuchMethodError: The method '[]' was called on null. Tried calling: [] ("is_ordered"). check for null fields Firebase

  14. 14

    Javascript Exception : unhandled method size()

  15. 15

    throws Exception in a method with Kotlin

  16. 16

    "Method must return a result" when calling another method that only throws an exception

  17. 17

    Calling asynchronous method of an interface

  18. 18

    Calling interface method of class

  19. 19

    Calling hidden interface method

  20. 20

    Artisan::call command package throws error exception will calling through web page

  21. 21

    Average of null list throws Exception on Razor View

  22. 22

    Calling dynamic callback function from an async method in the ScriptingObject of the BrowserControl throws Exception

  23. 23

    Calling a method and throws exception saying i'm passing in too many values... but i'm not

  24. 24

    Unhandled Exception: NoSuchMethodError: The method 'validate' was called on null

  25. 25

    Unhandled Exception: NoSuchMethodError: The method 'setString' was called on null

  26. 26

    Java 8 method reference unhandled exception

  27. 27

    Unhandled Exception: NoSuchMethodError: The method 'addUser' was called on null

  28. 28

    Unhandled Exception: NoSuchMethodError: The method 'toDate' was called on null

  29. 29

    Xamarin.Android: Async Task throws unhandled exception

HotTag

Archive