我对C#相当陌生,并且在将库加载到我的程序时遇到问题。我试着在Visual Studio中运行this的例子,但我得到了一个错误:TypeLoadException在C#中未处理#
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目录并重建? – 2012-03-08 19:45:14
你是什么意思集会?没有提到的行会导致错误,不幸的是 – Freek8 2012-03-08 19:57:13
EXE和DLL被称为程序集。 – 2012-03-09 21:24:42