Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Exception: Call to Node module failed with error: Error: Uncaught (in promise): Error: DI Error

$
0
0

After I created a base servise class I got this exception on the index.cshtml

System.Exception: Call to Node module failed with error: Error: Uncaught (in promise): Error: DI Error Error: DI Error at NoProviderError.ZoneAwareError (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:74842:33) at NoProviderError.BaseError [as constructor] (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:1312:20) at NoProviderError.AbstractProviderError [as constructor] (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:1438:20) at new NoProviderError (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:1478:20) at ReflectiveInjector_._throwOrNull (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:3010:23) at ReflectiveInjector_._getByKeyDefault (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:3049:29) at ReflectiveInjector_._getByKey (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:2981:29) at ReflectiveInjector_.get (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:2850:25) at AppModuleInjector.NgModuleInjector.get (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:8564:56) at CompiledTemplate.proxyViewClass.AppView.injectorGet (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:12008:49) at ElementInjector.get (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:11863:31) at ReflectiveInjector_._getByKeyDefault (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:3046:28) at ReflectiveInjector_._getByKey (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:2981:29) at ReflectiveInjector_.get (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:2850:25) at CompiledTemplate.proxyViewClass.AppView.injectorGet (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:12008:49) at resolvePromise (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:74515:31) [angular] at resolvePromise (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:74486:17) [angular] at C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:74563:17 [angular] at Object.onInvokeTask (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:4044:41) [angular] at ZoneDelegate.module.exports.ZoneDelegate.invokeTask (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:74216:36) [angular] at Zone.module.exports.Zone.runTask (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:74016:47) [ => angular] at drainMicroTaskQueue (C:\Projetos\Despesas\Desenv\20170313_Inicio\Fontes\Despesas\WA\ClientApp\dist\vendor.js:74396:35) [] at runMicrotasksCallback (internal/process/next_tick.js:58:5) [] at _combinedTickCallback (internal/process/next_tick.js:67:7) [] at process._tickCallback (internal/process/next_tick.js:98:9) []

at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance.d__7`1.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.d__14`1.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.d__10`1.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.d__10`1.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.SpaServices.Prerendering.PrerenderTagHelper.d__33.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.d__0.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at System.Runtime.CompilerServices.TaskAwaiter.GetResult()

at AspNetCore._Views_Home_Index_cshtml.d__31.MoveNext() in /Views/Home/Index.cshtml:line 2

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Mvc.Razor.RazorView.d__14.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Mvc.Razor.RazorView.d__13.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.d__18.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Mvc.ViewResult.d__26.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__30.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__28.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResultExecutedContext context)

at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__22.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context)

at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)

at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__20.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Builder.RouterMiddleware.d__4.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.SpaServices.Webpack.ConditionalProxyMiddleware.d__5.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.SpaServices.Webpack.ConditionalProxyMiddleware.d__5.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.d__7.MoveNext()

My code:

BaseService:

export class BaseService {
    private configApi = {
        host: "http://localhost:5000"
    };
    http: Http;
    mensagemService: MensagemService;

    constructor(_http: Http, _mensagenService: MensagemService) {
        this.http = _http;
        this.mensagemService = _mensagenService;
    }

    private obterOpcaoesRequest(sendToken: boolean): RequestOptions {
        let header = new Headers();

        header.append('Content-Type', 'application/json');

        if (sendToken) {
            header.append('Authorization', 'Bearer ' + "[TOKEN]");
        }

        let options = new RequestOptions({ headers: header });

        return options;
    }

    post<T>(url: string, data: any, callback: (retorno: T) => void, sendToken: boolean = true) {

        let dataJson = JSON.stringify(data);
        let options = this.obterOpcaoesRequest(sendToken);

        try {

            this.http.post(this.configApi.host + url, dataJson, options)
                .map(r => r.json())
                .subscribe(res => {
                    var result = res as ResultadoValidacao;

                    if (result.success) {
                        callback(result.objectReturn as T);
                    } else {
                        this.mensagemService.ShowInfos(result.infos);
                    }
                });

        } catch (e) {
            console.log(e);
        }
    }

}

UsuarioService:

@Injectable()
export class UsuarioService extends BaseService {

    constructor(_http: Http, _mensagemService: MensagemService) {
        super(_http, _mensagemService);
    }

    public criarUsuario(usuario: NovoUsuario, callback: (usuario: NovoUsuario) => void) {

        super.post<NovoUsuario>("/api/usuarios/criar", usuario, (user: NovoUsuario) => {
            callback(user);
        }, false);

    }
}

When I comment the constructor in the UsuarioService, the exception doesn't occurs. But the injectable parameters in the parameters constructor base class are not setted.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>