奇怪的NullReferenceException在第三方dll:C# [英] Weird NullReferenceException in third party dll: C#

查看:206
本文介绍了奇怪的NullReferenceException在第三方dll:C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的错误,突然开始,这让我疯狂。在我的C#应用​​程序中,我正在做一些重要的数学计算,为此,我正在使用CenterSpace的NMath库。最近,当我从Visual Studio 2015内部启动我的应用程序以进行调试时,由于NMath.dll中的NullReferenceExceptions,每当我调用NMath库方法(以及我们编写的另一个库)时,应用程序开始崩溃, 。为了隔离问题,我只运行以下非常基本的矩阵乘法代码:

  static void Main(string [] args )
{
var mA = new DoubleMatrix(100,200,1.5);
var mB = new DoubleMatrix(200,50,1.2);
var mC = NMathFunctions.Product(mA,mB);
Console.WriteLine(mC [5,6]);

Console.WriteLine(Computation finished);
Console.ReadLine();
}

代码在第三行崩溃,当我调用NMathFunctions.Product 方法,因为NullReferenceException,具有以下异常细节:



似乎它只是崩溃在NMathKernel对象的构造函数中,由于对象引用未正确设置。



最奇怪的是,当我直接从其运行完全相同的程序时使用Windows资源管理器的项目文件夹,不在Visual Studio中,程序运行正常:第四行按预期打印360.000000001,并达到Console.ReadLine()!



对于这个NullReferenceException错误的原因我完全无知。它似乎不是第三方dll相关的问题,因为程序只在Visual Studio中启动时崩溃。这个错误完全阻止我使用Visual Studio调试我的程序,这是一件很痛苦的事情,让我从Visual Studio外面的Console.WriteLine调用的唯一选项。这个问题可能是什么原因?是否有人搞砸了我的Build设置? (我已经检查过,没有发现任何错误的方式)任何线索或提示都非常受欢迎。

解决方案


  1. 在VisualStudio中,转到工具 - >选项 - >调试,并确保您有启用我的代码选项。

  2. 转到 Debug - >例外并取消所有抛出 chechboxes。只允许用户未处理的复选框。或者只需使用重置所有按钮。


I have a strange error, which has started suddenly and which is driving me crazy. In my C# application, I am doing some heavy mathematical calculations and for that purpose, I am using CenterSpace's NMath library. Recently, when I started my application from inside Visual Studio 2015 in order to debug it, the application started to crash because of NullReferenceExceptions in NMath.dll, whenever I call an NMath library method (and another library which we have written, as well). In order to isolate the problem, I just run the following very basic matrix multiplication code:

    static void Main(string[] args)
    {
        var mA = new DoubleMatrix(100, 200, 1.5);
        var mB = new DoubleMatrix(200, 50, 1.2);
        var mC = NMathFunctions.Product(mA, mB);
        Console.WriteLine(mC[5, 6]);

        Console.WriteLine("Computation finished");
        Console.ReadLine();
    }

The code crashes in the third line, when I call the "NMathFunctions.Product" method because of a NullReferenceException, with the following exception detail:

It seems that it crashes just in the constructor of the "NMathKernel" object, since an object reference is not properly set.

The most strange thing is, when I run the exactly same program directly from its project folder by using Windows Explorer, not within Visual Studio, the program runs perfectly: The fourth line prints "360.000000001" as expected and the "Console.ReadLine()" is reached!

I am completely clueless about the reason of this NullReferenceException error. It is not a third party dll related problem it seems, since the program only crashes when started from within the Visual Studio. This error completely blocks me from debugging my program with Visual Studio, which is a painful thing, leaves me the only option of debugging it with "Console.WriteLine" calls, from outside of Visual Studio. What can be the reason of this problem? Is something messed up with my Build settings maybe? (Which I have checked and found nothing out of order by the way) Any clues or hints are so much welcome.

解决方案

  1. In VisualStudio go to Tools -> Options -> Debugging and make sure you have Enable Just My Code option checked.
  2. Go to Debug -> Exceptions and unckeck all Thrown chechboxes. Only leave User-unhandled checkboxes checked. Or just use the Reset all button.

这篇关于奇怪的NullReferenceException在第三方dll:C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆