我看不出你在哪里调用 Assembly.Load,我认为这是必需的。在 Program.cs 中尝试这样做
using clojure.lang;
using System.Reflection;
// start up Clojure runtime including compiler
RT.Init();
// make .cljr file resources available from DLL
Assembly.Load("clojure.tools.nrepl");
Assembly.Load("clojure.tools.reader");
// compile nREPL lib
var ns = "clojure.tools.nrepl";
RT.var("clojure.core", "require").invoke(Symbol.intern(ns));
// create nREPL server (default port is 1667)
var startServer = RT.var(ns, "start-server!");
var server = startServer.invoke();
// allow exit on Ctrl-C by shutting down server
var stopServer = RT.var(ns, "stop-server!");
Console.CancelKeyPress += (_, _) => stopServer.invoke(server);
这里是一个合适的 example.csproj 文件
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Clojure" Version="1.12.0-alpha8" />
<PackageReference Include="clojure.tools.nrepl" Version="0.1.0-alpha1" />
</ItemGroup>
</Project>
我在 Ubuntu 22.04 上使用 dotnet 7.0.114。在空的目录中放这两个文件,只需运行
dotnet restore
dotnet run
祝你好运!