即使我的应用程序包含在 Router 标签中,当我使用useNavigate()或<Navigate />元素时,我也会收到相同的错误login.tsx:27 Error: Make sure your app is wrapped in a <Router />
这是我的index.tsx
/* @refresh reload */
import { render } from 'solid-js/web';
import './index.css';
import App from './App';
import { Router } from 'solid-app-router';
render(
    () => (
        <Router>
            <App />
        </Router>
    ),
    document.getElementById('root') as HTMLElement
)
Run Code Online (Sandbox Code Playgroud)
应用程序.tsx
const App: Component = () => {
    return (
        <>
            <Routes>
                <Route path="/" component={Landing} />
                <Route path="/dashboard" component={Dashboard} />
            </Routes>
        </>
    )
} …Run Code Online (Sandbox Code Playgroud) 在 IIS Express 上从 Visual Studio 2019 运行我的应用程序时,网页给出错误 500.30 并在输出中显示,
Exception thrown: 'System.NullReferenceException' in System.Private.CoreLib.dll
Run Code Online (Sandbox Code Playgroud)
但是,在使用dotnet watch run该页面的终端中运行它时,运行没有错误并正确显示。
我试过运行调试器,错误总是在这一行抛出,
CreateHostBuilder(args).Build().Run();
Run Code Online (Sandbox Code Playgroud)
在我下面的 ConfigureServes 方法完成后
// This method gets called by the runtime. Use this method to add services to the container.
        public static void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddRouting();
        }
Run Code Online (Sandbox Code Playgroud)
我还尝试修复我的 Visual Studio 2019 以及重新安装 .NET 3.1.100 SDK,但没有成功。
任何帮助将不胜感激!
编辑:
我必须发布程序然后运行 .exe,但这是我得到的输出
crit: Microsoft.AspNetCore.Hosting.Diagnostics[6]
      Application startup exception
System.IO.DirectoryNotFoundException: C:\Users\ray.kochenderfer\Documents\public\hub\public\
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters)
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root)
   at QualityHub.Startup.Configure(IApplicationBuilder …Run Code Online (Sandbox Code Playgroud) 对于我的项目,我想在项目构建时将项目根目录中的文件 config.ron 复制到目标目录。我知道你可以使用 include_str!在编译时将文件的内容添加到程序中,但我希望该文件保留在目标文件夹的根目录中,以便可以对其进行编辑而无需重新编译程序。
我目前一直在尝试构建脚本来完成此任务,但我没有运气。
use std::process::Command;
use std::env;
fn main() {
    let profile = std::env::var("PROFILE").unwrap();
    match profile.as_str() {
        "debug" => {
            Command::new("cmd")
                .args(&["copy", "/y"])
                .arg(&format!(r#"{}\config.ron"#, env::var("CARGO_MANIFEST_DIR").unwrap()))
                .arg(&format!(r#"{}\target\debug"#, env::var("CARGO_MANIFEST_DIR").unwrap()))
                .status()
                .expect("Copy failed to execute.");
            ()
        },
        "release" => {
            Command::new("cmd")
                .args(&["copy", "/y"])
                .arg(&format!(r#"{}\config.ron"#, env::var("CARGO_MANIFEST_DIR").unwrap()))
                .arg(&format!(r#"{}\target\release"#, env::var("CARGO_MANIFEST_DIR").unwrap()))
                .status()
                .expect("Copy failed to execute.");
            ()
        },
        _ => (),
    }
}
Run Code Online (Sandbox Code Playgroud)
使用构建脚本将此文件复制到目标目录的正确方法是什么?