简体   繁体   English

AspNetCore InvalidOperationException

[英]AspNetCore InvalidOperationException

I am getting the following error:我收到以下错误:

System.InvalidOperationException: Unable to resolve service for type 
'Microsoft.AspNetCore.NodeServices.INodeServices' while attempting to activate 
'ConvertHighchart.Controllers.runNodeScriptController'.

My controller code is this:我的 controller 代码是这样的:

using Microsoft.AspNetCore.NodeServices;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace ConvertHighchart.Controllers
{
[ApiController]
[Route("[controller]")]
public class runNodeScriptController : ControllerBase
{
    private readonly INodeServices _nodeServices;
    public runNodeScriptController(INodeServices nodeServices)
    {
        _nodeServices = nodeServices;
    }

    [HttpPost]
    public async Task<IActionResult> Post()
    {
        var result = "";
        try
        {
            result = await _nodeServices.InvokeExportAsync<string>("test_nodejs_script",
              "generateHighChart",
              "abc");
        }
        catch (System.Exception ex)
        {
        }

        return Ok(result);
    }
  }
}

Thanks谢谢

If you see this error while sending POST requests to the endpoint, have you put services.AddNodeServices();如果您在向端点发送 POST 请求时看到此错误,您是否将services.AddNodeServices(); in Startup?在启动?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AspNetCore NodeServices抛出NodeInvocationException - AspNetCore NodeServices throws NodeInvocationException 如何解决“ Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException” - How do i solve 'Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException' 更新 angular-devkit 并失败:Microsoft.AspNetCore.SpaServices[0] - Update angular-devkit and got fail: Microsoft.AspNetCore.SpaServices[0] 带有React的ASP.NET Core 2.2 InvalidOperationException:无法启动&#39;npm&#39; - ASP.NET Core 2.2 with React InvalidOperationException: Failed to start 'npm' 使用Microsoft.AspNetCore.NodeServices调用JS文件时,获取节点调用超时错误 - Getting Node invocation timed out error when invoking JS file using Microsoft.AspNetCore.NodeServices Microsoft.AspNetCore.SpaServices由于节点模块map.d.ts而失败 - Microsoft.AspNetCore.SpaServices fail due to node module map.d.ts Azure Node.js Linux 应用服务 Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException:请求正文太大 - Azure Node.js Linux App Service Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Request body too large Getting error while creating pdf using html-pdf node package and Microsoft.AspNetCore.NodeServices in Azure web app - Getting error while creating pdf using html-pdf node package and Microsoft.AspNetCore.NodeServices in Azure web app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM