【问题标题】:.NETCore Application terminating due to StackOverflowException.NETCore 应用程序因 StackOverflowException 而终止
【发布时间】:2017-08-22 22:21:01
【问题描述】:

所以,

我正在使用 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);
    }
}

【问题讨论】:

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


    【解决方案1】:

    检查访问自身的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;
            }
        }
    

    【讨论】:

    • 我讨厌它这么简单,我想知道为什么 Visual Studios 没有选择它,你会期望它指出属性中的自引用。
    • 我已经更改了它,但我回家之前无法测试,所以今晚将测试并通知您。
    • 感谢工作完美:) 现在只需弄清楚为什么它能够写入一个文件而不是其他文件:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-04
    • 1970-01-01
    • 2018-09-06
    • 2020-11-02
    • 1970-01-01
    • 1970-01-01
    • 2015-11-10
    相关资源
    最近更新 更多