我對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