私は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のディレクトリを削除して再構築しようとしましたか? –
アセンブリではどういう意味ですか?残念ながらエラーの原因となる行はありません – Freek8
EXEとDLLはアセンブリと呼ばれます。 –