【发布时间】:2012-11-08 21:53:35
【问题描述】:
我是 C# 的新手,在将库加载到我的程序时遇到问题。我试图在 Visual Studio 中运行 this 示例,但出现错误:
TypeLoadException was unhandled. Can't load type SVM.Problem from assembly SVM, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
这是我的代码的样子:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SVM;
namespace SVM
{
class Program
{
static void Main(string[] args)
{
//First, read in the training data.
Problem train = Problem.Read("a1a.train");
Problem test = Problem.Read("a1a.test");
//For this example (and indeed, many scenarios), the default
//parameters will suffice.
Parameter parameters = new Parameter();
double C;
double Gamma;
//This will do a grid optimization to find the best parameters
//and store them in C and Gamma, outputting the entire
//search to params.txt.
ParameterSelection.Grid(train, parameters, "params.txt", out C, out Gamma);
parameters.C = C;
parameters.Gamma = Gamma;
//Train the model using the optimal parameters.
Model model = Training.Train(train, parameters);
//Perform classification on the test data, putting the
//results in results.txt.
Prediction.Predict(test, "results.txt", model, false);
}
}
}
我已通过解决方案资源管理器添加 dll 作为参考。可能出了什么问题?
我已经开始了一个新项目,添加了 dll 作为参考,运行了该项目,现在一切正常。不知道出了什么问题非常令人沮丧,但我怀疑这与项目名称和 dll 名称相同有关。感谢您的帮助!
【问题讨论】:
-
需要从细节,哪些程序集是程序和问题。哪一行导致异常。你们每个程序集是在什么平台上编译的,参考版本是特定的吗?您是否尝试删除 bin 和 obj 目录并重建?
-
组装是什么意思?不幸的是,没有提到导致错误的行
-
EXE 和 DLL 被称为程序集。