【问题标题】:Waiting for a file to change before restarting dotnet error在重新启动 dotnet 错误之前等待文件更改
【发布时间】:2017-06-13 15:19:23
【问题描述】:

我正在使用 asp.net 核心、剃须刀引擎和实体框架。当我尝试使用 dotnet watch run 在 VS 代码中运行我的代码时出现此错误。这是完整的错误。

Project c-login (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
A JSON parsing exception occurred in [/Users/aaronmk2/Desktop/CodingDojo/c#/asp.net/entity/c-
login/bin/Debug/netcoreapp1.0/c-login.deps.json]: * Line 1, Column 2 Syntax error: Malformed
token
Error initializing the dependency resolver: An error occurred while parsing /Users/aaronmk2/D
esktop/CodingDojo/c#/asp.net/entity/c-login/bin/Debug/netcoreapp1.0/c-login.deps.json
[DotNetWatcher] fail: dotnet exit code: 139
[DotNetWatcher] info: Waiting for a file to change before restarting dotnet...

以前有人见过这个错误吗?解决方法是什么?

【问题讨论】:

  • 如果你只运行“dotnet run”,它是否运行没有错误?
  • @RickHodder,不,当我尝试 dotnet run 时遇到同样的错误
  • 我会检查它正在讨论的 json 文件是否有错误:您可以将其粘贴到 jsonlint.com 中。
  • 你能分享一下哪里出了问题,以便其他人遇到它,他们会在这里找到答案吗?我对 json 的看法是对的吗?
  • 我只需要删除我的 bin 文件并运行 dotnet restore 和 dotnet watch run 即可。

标签: c# asp.net-mvc visual-studio razor


【解决方案1】:

我遇到了同样的错误,在尝试了所有方法后,我发现这是因为证书损坏。由于某种原因,我的证书损坏了,所以我不得不删除旧的并生成一个新的。 生成:

dotnet dev-certs https

信任:

dotnet dev-certs https --trust

【讨论】:

    【解决方案2】:

    我收到了同样的错误,但我还有其他错误。我遇到的问题是我试图使用 Microsoft 凭据(例如使用 Server=(LocalDB))连接到我的 appsettings.json 文件中的服务器。将其更新为连接数据库的 MacOS 方式后,它可以工作了。

    我从

    "DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=ShirtDB;Trusted_Connection=True;MultipleActiveResultSets=true"
    

    "DefaultConnection": "Server=localhost,*port number*;Database=MyDB;User ID=sa;Password=******"
    

    【讨论】:

    • 请您解释一下这与问题有何关系。
    • @MikePoole 我在答案的开头添加了一句话,希望对您有所帮助。主要问题是“以前有人见过这个错误吗?解决方法是什么?”我收到了同样的错误。我提供了我使用的“解决方法”,以防有人遇到类似问题。
    【解决方案3】:

    虽然这已经解决了,但我想提供另一个解决方案,因为我找不到关于这个特定错误的太多信息。

    我在使用 MySQL 时遇到了类似的问题,如下所示:

    A JSON parsing exception occurred in [C:\foo\bin\Debug\netcoreapp3.1\foo.deps.json]: * Line 1, Column 2 Syntax error: Malformed token
    Error initializing the dependency resolver: An error occurred while parsing: C:\foo\bin\Debug\netcoreapp3.1\foo.deps.json
    

    我最终放弃了我的架构并删除了我以前的所有迁移,然后它开始正常工作。我最好的理论是我对模型所做的某些事情导致了它。希望这可以帮助某人。

    【讨论】:

      【解决方案4】:

      我认为,您只需成功构建项目并重新启动服务器即可。它对我有用。

      【讨论】:

        猜你喜欢
        • 2023-02-12
        • 1970-01-01
        • 2021-07-02
        • 1970-01-01
        • 1970-01-01
        • 2020-11-07
        • 2020-09-13
        • 2019-12-15
        • 2022-11-11
        相关资源
        最近更新 更多