c# - .NETCore 应用程序因 StackOverflowException 而终止

标签 c# exception raspberry-pi .net-core

所以,

我使用的是 Raspberry Pi 型号 3b,并且我已成功在其上运行 .NetCore v2.0.1。我已经能够构建 CoreIOT Hello World 项目并在我的 Pi 上毫无问题地运行它,现在我有一些使用 GPIO 板创建的自定义硬件,我认为在 .NETCore 中使用它的唯一方法是使用 FileSystem方法 /sys/class/gpio 我构建了一个非常小的应用程序

https://github.com/barkermn01/CanReader

里面没有太多内容,但出于某种原因,当我运行该应用程序时,我得到的只是一条消息,内容为 Proccess is terminating due to StackOverflowException 我不确定是什么原因导致的,没有任何内容里面太大了,我不认为只是基本的文件系统读取。

我唯一能想到的是它不喜欢无限循环

发件人:https://github.com/barkermn01/CanReader/blob/master/Program.cs

while (!exiting)
{
    Console.Write("\rCurrent State " + state);
    string input = Console.ReadLine();
    if (input == "exit")
    {
        watcher.Stop();
        exiting = true;
    }
}

来自:https://github.com/barkermn01/CanReader/blob/master/GPIOWatcher.cs

public void watch()
{
    GPIO.Value val = Gpio.ReadValue();
    while (val != OldValue)
    {
        val = Gpio.ReadValue();
        if (Delegate != null)
        {
            Delegate.DynamicInvoke();
        }
        Thread.Sleep(10);
    }
}

最佳答案

检查 property getter of GPIO.FullPath它访问自己:

   /// <summary>
    /// Generates the full path for the Filesystem mappings for this GPIO pin
    /// </summary>
    public string FullPath
    {
        get
        {
            return this.Path + "/" + this.FullPath;
        }
    }

关于c# - .NETCore 应用程序因 StackOverflowException 而终止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45827872/

相关文章:

c# - WPF:MVVM - 如果命令为空则禁用按钮

c# - 在另一个线程中抛出异常时不调用 UnhandledException

android - 用于上传图像/视频并通过智能手机应用程序查看的物联网 API

c# - LINQ 到 SQL : InsertOnSubmit() vs Add()

c# - 如何返回一个已取消的 ValueTask<T> 并传播一个 OperationCanceledException,而不需要 async/await?

android - java.lang.IllegalArgumentException : View not attached to window manager 异常

c# - Crittercism 崩溃报告未交付

javascript - setInterval 没有被清除,函数一直在执行

c - ESC电机不改变速度

c# - 从服务在事件用户 session 中启动程序?