在G-WAN中使用C#dll

在G-WAN中使用C#dll,c#,dll,centos,mono,g-wan,C#,Dll,Centos,Mono,G Wan,我的目标是应用在G-WAN上运行并连接到Azure存储的创建脚本。所以为了实现这一点,我首先尝试如何将dll链接到G-WAN中的C#脚本,我遇到了这个错误 Error: test.cs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Package TestGwanLibrary was not found in the pkg-config search path. Perhaps you sho

我的目标是应用在G-WAN上运行并连接到Azure存储的创建脚本。所以为了实现这一点,我首先尝试如何将dll链接到G-WAN中的C#脚本,我遇到了这个错误

Error: test.cs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Package TestGwanLibrary was not found in the pkg-config search path.
Perhaps you should add the directory containing `TestGwanLibrary.pc'
to the PKG_CONFIG_PATH environment variable
No package 'TestGwanLibrary' found
error CS8027: Error running pkg-config. Check the above output.

1|// pragma link TestGwanLibrary
2|using System;
3|using System.Collections.Generic;
4|
5|public class Program
6|{
7|    public static int Main (string[] args)
8|    {


To run G-WAN, you must fix the error(s) or remove this Servlet



Error(s) in testdll.cs
我的C#servlet脚本如下

// pragma link TestGwanLibrary
using System;
using System.Collections.Generic;

public class Program
{
    public static int Main (string[] args)
    {
        Console.WriteLine ("Running test.cs");
        TestGwanClass2.PrintToConsole2 ("ptc2 test");
        return 200;
    }
}
按照中的说明,我已将GameCloudLibrary.dll放入

root/gwan_linux64-bit/libraries/cs/dll
但是,在运行gwan时,我遇到了以下错误。我还尝试添加一个MONO_路径,它指向

/root/gwan_linux64-bit/libraries/cs/dll
但上述错误仍未解决

我当前的设置如下

// pragma link TestGwanLibrary
using System;
using System.Collections.Generic;

public class Program
{
    public static int Main (string[] args)
    {
        Console.WriteLine ("Running test.cs");
        TestGwanClass2.PrintToConsole2 ("ptc2 test");
        return 200;
    }
}
  • 世纪7.1804
  • G-WAN 7.12.6 64位(2016年2月8日16:33:28)
  • Mono JIT编译器版本3.0.2(tarball Wed Sep 5 03:46:28 EDT 2018)
下面是使用.NET标准2.0的类库 使用制度

namespace TestGwanLibrary
{
    public class TestGwanClass
    {
        public static void PrintToConsole (string message)
        {
            Console.WriteLine ("PrintToConsole : " + message);
        }
    }
}

public class TestGwanClass2
{
    public static void PrintToConsole2 (string message)
    {
        Console.WriteLine ("PrintToConsole2 : " + message);
    }
}

我不知道该如何处理这个错误。有人,请告诉我我错过了什么

我们使用G-WAN C#脚本已经有一段时间了(我们使用G-WAN的主要目标是C脚本),而C#运行时的发展方式可能已经打破了这一局面(Java、Objective-C、D和其他语言一直导致这种向后兼容性问题)

我想,在一些人看来,这是“不可阻挡的进步之路”

约翰(上图)可能建议将你的G-WAN C#库的功能嵌入到C#脚本中(或作为G-WAN/libraries文件夹中的源代码)——除非你的库很大并且被数百个脚本使用,否则就不会有pennalties(速度、内存)


但是,如果您面临这种运行时开销问题,那么我建议使用更简单的运行时,如
ansic
。这也有利于可伸缩性。

第一个问题:TestGwanLibrary.pc缺失

Package TestGwanLibrary was not found in the pkg-config search path.
Perhaps you should add the directory containing `TestGwanLibrary.pc'
to the PKG_CONFIG_PATH environment variable
No package 'TestGwanLibrary' found
error CS8027: Error running pkg-config. Check the above output.
为了解决这个问题,我在/usr/lib64/pkgconfig中创建了TestGwanLibrary.pc,内容如下所示

Name: TestGwanLibrary
Description: Test dll for using C# in G-WAN
Version: 1.0.0.0
Libs: -r:/root/gwan_linux64-bit/libraries/cs/dll/TestGwanLibrary.dll
我曾尝试将TestGwanLibrary.pc放在/usr/lib/pkgconfig和/usr/share/pkgconfig中,这两个文件都不起作用,因此我猜gwan binary只在/usr/lib64/pkgconfig中搜索包

在TestGwanLibrary.pc中,Libs指向存储自定义.dll的位置,即../gwan/libraries/cs/dll/。这个位置不能更改,因为我相信gwan中有一些设置可以搜索这个特定的目录

第二个问题:未引用程序集“netstandard”

/root/gwan_linux64-bit/0.0.0.0:8080/#0.0.0.0
/csp/testdll.cs(12,24): error CS0012: The type `System.Object' is defined in an assembly that
is not referenced. Consider adding a reference to assembly `netstandard, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
Compilation failed: 1 error(s), 0 warnings
此问题是由于mono不支持.NET标准2.0,而我的库是使用此框架构建的。为了解决这个问题,我构建了另一个以.NETFramework4.6.1为目标的库


因此,对于中的C#部分,您需要在目录/usr/lib64/pkgconfig中为您的库创建一个包文件(.pc),如上所述。

您不能将其与应用程序一起放置吗?@John,我不明白您的意思我不能嵌入我需要的功能,因为我没有Azure的源代码,为了解决这个问题,我需要包含这些库的.dll。编辑:无论如何,我已经找到了我的设置中缺少的东西,我会在一段时间后发布一个答案。