运行C# SplashKit代码时遇System.DllNotFoundException错误求助
运行以下C#代码:
using System; using SplashKitSDK; namespace HelloWorld { public class Program { public static void Main() { Console.WriteLine("Hello World"); Window w = new Window("My First program", 200, 100); w.DrawText("Hello World", Color.Black, 10, 45); w.Refresh(60); SplashKit.Delay(5000); } } }
得到如下错误输出:
Hello World
Unhandled exception. System.DllNotFoundException: Unable to load DLL 'SplashKit' or one of its dependencies: The specified procedure could not be found. (0x8007007F)
at SplashKitSDK.SplashKit.__sklib__open_window__string__int__int(__sklib_string caption, Int32 width, Int32 height)
at SplashKitSDK.SplashKit.OpenWindow(String caption, Int32 width, Int32 height)
确认SplashKit核心DLL部署到程序输出目录
编译完成后,splashkit.dll必须与你的可执行文件位于同一文件夹(如bin/Debug/netX.X或bin/Release/netX.X)。若通过NuGet安装SDK,检查NuGet包是否自动复制DLL到输出目录;手动安装的话,直接将DLL复制到对应路径。匹配SplashKit SDK与项目.NET版本
确保安装的SplashKit SDK版本支持当前项目使用的.NET框架/版本(如.NET 6、.NET 7),版本不兼容会导致无法找到指定函数过程。安装系统依赖库
SplashKit依赖系统级组件(如Windows的Visual C++ Redistributable),需安装对应版本的VC++运行时库,且32位/64位要与项目平台一致。对齐项目平台与DLL架构
项目平台目标(x64/x86)必须与SplashKit DLL的架构匹配:x64项目用64位DLL,x86项目用32位DLL。可在项目属性的“生成”选项中确认平台设置,再替换对应架构的DLL。
内容的提问来源于stack exchange,提问作者Lingutla Prem Kumar

