我正在制作this NuGet包(source),它包含了一个dll libxgboost.dll
(由XGBoost构建)。但是,它目前正在抛出异常,因为它找不到libxgboost.dll
。
如何将libxgboost.dll
包含在我的NuGet包中,以便我可以将其解锁?
调用代码(已安装软件包)
using System;
using XGBoost;
namespace TestXGBoostPackage
{
class Program
{
static void Main(string[] args)
{
XGBRegressor r = new XGBRegressor();
float[][] X = new float[2][];
X[0] = new float[2];
X[0][0] = 0;
X[1] = new float[2];
X[1][0] = 1;
float[] y = {0, 1};
r.Fit(X, y);
Console.ReadKey();
}
}
}
通过调用Fit()
抛出异常An unhandled exception of type 'System.DllNotFoundException' occurred in XGBoost.dll
Additional information: Unable to load DLL 'libxgboost.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
函数的DLL导入语句由Fit()
引入[DllImport("libxgboost.dll")]
public static extern int XGDMatrixCreateFromMat(float[] data, ulong nrow, ulong ncol,
float missing, out IntPtr handle);
包的nuspec文件
<?xml version="1.0"?>
<package >
<metadata>
<id>PicNet.XGBoost</id>
<version>0.0.2.1</version>
<title>XGBoost.Net</title>
<authors>John Smith</authors>
<owners>John Smith</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
<projectUrl>https://github.com/PicNet/XGBoost.Net</projectUrl>
<iconUrl>http://www.picnet.com.au/wp-content/uploads/2015/01/logo-dark.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>.Net wrapper for the XGBoost machine learning library.</description>
<releaseNotes>test dll dependency fix</releaseNotes>
<copyright>Copyright 2016</copyright>
<tags>machine learning xgboost boosted tree</tags>
</metadata>
</package>
在软件包的项目属性中,构建输出路径为bin\Debug\
,平台目标为x64
。
答案 0 :(得分:1)