完成的步骤:
当我启动 C# 程序时,出现以下错误:
System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly 'grpc_server_processing, Version=1.0.8900.14343, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. Source=<Cannot evaluate the exception source> StackTrace: <Cannot evaluate the exception stack trace>
C++ DLL 就在它应该在的位置,我也尝试将 DLL 复制到与 C# 可执行文件相同的文件夹,同样的错误。在 Visual Studio 之外启动 C# 可执行文件:同样的错误。错误消息中DLL的版本号与我在Visual Studio中对象浏览器中看到的相同:
我不知道出了什么问题,非常欢迎任何帮助。
供快速参考的自我回答,感谢评论中的@Ralf 填补了我的盲点。
事实证明,C# 可执行文件需要 MS ijwhost.dll 来加载 C++/CLR 库。必须将该 DLL 复制到与 C# 可执行文件相同的文件夹中,然后才能正常工作。