安装NuGet包DirectCelik时.NET Framework项目添加引用失败求助
安装NuGet包DirectCelik时在.NET Framework项目中遇非托管DLL引用错误
从NuGet.org安装自制包DirectCelik时,出现如下错误:
Failed to add reference to 'XYZ', please make sure that the file is accessible, and that it is a valid assembly or COM component.
错误中的XYZ是随包分发的非托管DLL CelikApi32(同包的CelikApi64暂未出现报错),且该错误无NU5100这类官方错误代码。
问题触发特征
- 仅在目标框架为.NET Framework 3.5/4.6的项目中出现,.NET 8项目完全正常
- 该NuGet包本身以.NET Framework 3.5为目标框架
当前临时解决办法
手动在.csproj文件中添加以下代码可绕过问题:
<PackageReference Include="DirectCelik" Version="1.0.1" />
但此方法不适用于公共包的长期维护,寻求根本解决方案。
内容的提问来源于stack exchange,提问作者DeltaJuliet2k
相关产品推荐
相关产品推荐

