【问题标题】:Porting winform application to run on raspberry PI移植 winform 应用程序以在树莓派上运行
【发布时间】:2016-04-20 21:30:18
【问题描述】:

我有一个 c# winform 应用程序,我想移植它以在我的新 Raspberry PI 3 上运行。我处于呻吟模式,因为我认为我的应用程序会运行。根本不是这样。我的 winform 应用程序使用夸脱。 net、aforge 库和常见的 .net 库,例如 system.configuration。 我虽然会从我的日志类开始,因为有人提到如果需要更改任何内容,非 UI 代码应该很容易转换。 这看起来我将不得不重新发明轮子。具体来说,请查看下面的函数。任何使用system.configuration 的代码都不起作用。 有没有更简单的方法可以让我的应用程序正常工作,或者我必须从字面上转换几乎所有的代码。 aforge 库甚至会在 PI 上工作吗? quart.net 能用吗? 现在我想放弃并购买一台运行“正确”窗口的小型 Windows PC。

C# Winform 代码

class Logging
{

    public void Write_To_Log_File(String Message, String Procedure, String Error_Code, String Error_String)
    {
        try
        {
            // If the log file is bigger than allowed size then archive
            if (File.Exists(@ConfigurationManager.AppSettings["LogSavePath"]))
            {

                FileInfo file = new FileInfo(@ConfigurationManager.AppSettings["LogSavePath"]);
                if (file.Length > Convert.ToInt32(ConfigurationManager.AppSettings["FileLogSizeLimit"]))
                {
                    // Rename the file
                    File.Move(@ConfigurationManager.AppSettings["LogSavePath"], @ConfigurationManager.AppSettings["LogSavePath"] + string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", DateTime.Now) + ".csv");
                }

            }
            // If log file does not exist then create it and add the headers
            if (File.Exists(@ConfigurationManager.AppSettings["LogSavePath"]))
            {
            }
            else
            {
                // Create the file
                System.IO.File.Create("LogSavePath");
                // Add data
                string[] Headers = { "Time" + "," + "_Message" + "," + "Procedure" + "," + "Error_Code" + "," + "Error_String" };
                System.IO.File.AppendAllLines(@ConfigurationManager.AppSettings["LogSavePath"], Headers);
            }
            if (File.Exists(@ConfigurationManager.AppSettings["LogSavePath"]))
            {
                string[] Log = { DateTime.Now.ToString() + "," + Message + "," + Procedure + "," + Error_Code + "," + Error_String };
                System.IO.File.AppendAllLines(@ConfigurationManager.AppSettings["LogSavePath"], Log);
            }

        }
        catch
        {

        }
    }
}

【问题讨论】:

  • 可能需要重写,因为 Rasberry 只支持单声道环境,不支持 microsoft .net 框架。此外,任何不符合 pcl 的库也将不起作用。对你来说好消息是 Quartz.net 和 Aforge 都受支持,正如我所读到的那样。
  • Windows IoT 版本应该可以在板上运行,但这意味着操作系统的变化。如果您不想要那个 l,正如其他评论所指出的那样,您可以查看 Mono 或 .NET Core。但由于已知问题,WinForms 可能不会很好地工作。

标签: c# winforms iot windows-10-iot-core raspberry-pi3


【解决方案1】:

微软为此推出了 Windows 10 IoT Core Porting Tool。这可以帮助您从 Win32 应用和库迁移到 Windows 10 IoT Core 应用。更多细节在这里:https://developer.microsoft.com/en-us/windows/iot/win10/tools/iotapiportingtool

【讨论】:

  • @user1438082 提醒:如果您能够解决您的问题,请提供答案,或者将其中一个答案标记为已接受,它可以解决您的问题。谢谢。
猜你喜欢
  • 2021-12-07
  • 2020-03-27
  • 1970-01-01
  • 2019-05-17
  • 1970-01-01
  • 1970-01-01
  • 2022-12-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多