谁能解释为什么我得到TypeLoad异常,而使用MathNet.com数字库
本文关键字:MathNet com 数字 异常 为什么 能解释 TypeLoad | 更新日期: 2023-09-27 18:15:34
我得到一个奇怪的系统。动作typeloadeexception而乘两个矩阵,有人能帮助吗?
我在32位VS2008中创建了一个新项目,并将目标框架更改为2.0,包括MathNet.Numerics.dll并执行以下代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Numerics;
using MathNet.Numerics.Statistics;
using MathNet.Numerics.LinearAlgebra;
using MathNet.Numerics.LinearAlgebra.Double;
using MathNet.Numerics.LinearAlgebra.Double.Factorization;
namespace MathNetTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double[,] A = new double[3, 3];
A[0, 0] = 1;
A[0, 1] = 0.2;
A[0, 2] = 1;
A[1, 0] = 1.5;
A[1, 1] = -1.2;
A[1, 2] = 1.1;
A[2, 0] = 0.45;
A[2, 1] = 2.1;
A[2, 2] = -0.76;
Matrix XA = new DenseMatrix(A);
Matrix XB = new DenseMatrix(A);
Matrix C = (Matrix)(XA * XB); // throws a TypeLoadException
}
}
}
MathNet。数字系统需要。net Framework #4.0。数字支持。
我在单声道/MS没有这样的问题。NET #4.0(见下面的例子)
这是从google code
下载的库如果我的答案没有帮助你,检查GAC中冲突的MathNet版本,最好设置引用t
- Copy Local = true
- 指定版本= true
Mono 2.10.x:
最小测试程序(控制台应用程序):
using MathNet.Numerics.LinearAlgebra.Double;
public class Program
{
public static void Main(string[] args)
{
double[,] A = new double[3, 3];
A[0, 0] = 1;
A[0, 1] = 0.2;
A[0, 2] = 1;
A[1, 0] = 1.5;
A[1, 1] = -1.2;
A[1, 2] = 1.1;
A[2, 0] = 0.45;
A[2, 1] = 2.1;
A[2, 2] = -0.76;
Matrix XA = new DenseMatrix(A);
Matrix XB = new DenseMatrix(A);
Matrix C = (Matrix)(XA * XB); // throws a TypeLoadException
}
}
编制dmcs -optimize+ -reference:MathNet.Numerics.dll test.cs
运行很好
Win64 MS.NET 4.0:
更新在VS2010 (WinXP 64)上也没有问题:
T:'lib'Net40>csc test.cs -reference:MathNet.Numerics.dll
Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.
T:'lib'Net40>.'test.exe