小编pat*_*vax的帖子

使用 C#、.NET Core 3 和 GTK# 进行跨平台编程(和替代方案)

我即将开始开发一个软件项目,如果可能的话,该项目应该在 Linux 和 Windows 上运行。由于我已经有一些 C# 经验,所以我渴望将它用于这个项目。我认为对于 .NET Core 3 和 GTK# 3.22 这应该不是问题,因为 .NET Core 应用程序应该是开箱即用的跨平台。GTK# - 根据我的理解 - 应该可以在任何地方使用相同版本的 GTK+。

为什么是 C#?嗯,我只是喜欢这种语言,而且我想使用一个适用于 c# 的 ECS 框架。

到目前为止,我已经在 Visual Studio 中设置了一个针对 .NET Core 3 的测试控制台应用程序项目,并添加了GTK# 特定的 NuGet 包

我写了一个简单的Hello World程序来测试环境。

using System;
using Gtk;

namespace GTKTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Application.Init();
            Window win = new Window("Hello GTK");
            Label lbl = new Label("This is a test GTK App written with C# for GNU/Linux …
Run Code Online (Sandbox Code Playgroud)

c# mono cross-platform gtk# .net-core

6
推荐指数
1
解决办法
8346
查看次数

.NET Core 3 中的 DLLExport 用于非托管 C/C++ 代码

我在 GitHub 上找到了DllExport项目,同时正在寻找一种使用普通 C/C++ 中的 C# .NET Core 3 代码的方法。我的目标是能够将 C# 编译为任何动态库,并在 Linux 或 Windows 上使用 dlopen ( dlopen for Windows )使用它。

我正在尝试创建的 C# 库:

using RGiesecke.DllExport;
using System;

namespace CSharpPart
{
    public class Test
    {
        [DllExport]
        public static int _add(int a, int b)
        {
            return a + b;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我试图引用 C# 库的 C/C++ 代码:

#include "CPartCMake.h"
    #include "dlfcn.h"
    #include "cstring"

    using namespace std;

    int main()
    {
        const char* pemodule = "path_to_dll\\CSharpPart.dll";
        void* handle = dlopen(pemodule, …
Run Code Online (Sandbox Code Playgroud)

c# c++ cross-platform dllexport .net-core

5
推荐指数
0
解决办法
1354
查看次数

标签 统计

.net-core ×2

c# ×2

cross-platform ×2

c++ ×1

dllexport ×1

gtk# ×1

mono ×1