0

My goal here is to apply create scripts that runs on G-WAN and connects to Azure Storage. So to achieve this, I am first trying out how to link dll to C# script in G-WAN and I encountered this error

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

My C# servlet script is as follows

// 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;
    }
}

Following instructions in G-WAN FAQ, I have placed GameCloudLibrary.dll in

root/gwan_linux64-bit/libraries/cs/dll

However, i am getting the following error when i run gwan. I have also tried adding a MONO_PATH, which is pointing to

/root/gwan_linux64-bit/libraries/cs/dll

but the error above remains unsolved.

My current setup is as follows

  • CentOS7.1804
  • G-WAN 7.12.6 64-bit (Feb 8 2016 16:33:28)
  • Mono JIT compiler version 3.0.2 (tarball Wed Sep 5 03:46:28 EDT 2018)

Below is the class library, using .NET Standard 2.0 using System;

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);
    }
}

I am not sure how i should proceed with this error. Someone, please advice me on what I am missing!

2 Answers2

0

It's been a while that we have used G-WAN C# scripts (our main goal with G-WAN was C scripts) and the C# runtime might have evolved in a way that broke things (Java, Objective-C, D, and other languages have consistently caused this kind of backward compatibility issues).

I suppose that, in the mind of some, this is the "unstoppable march of progress".

What John (above) probably suggested is to embed the features of your G-WAN C# library in the C# script (or as source code in the G-WAN /libraries folder) - there will be no pennalties (speed, memory) unless your library is huge and used by hundreds of scripts.

But if you are facing this kind of runtime overhead issues then I would suggest using a simpler runtime like ANSI C. This will also benefit to scalability.

Gil
  • 3,279
  • 1
  • 15
  • 25
  • 1
    I can't embed the features i need because I do not have the source code of Azure, so to solve that i will need to include .dll of those libraries. edit: Anyway, I have found out what was missing in my setup and I will post an answer in a while. – Tan Wei Liang Sep 07 '18 at 06:48
0

First issue : TestGwanLibrary.pc is missing.

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.

To solve this, I created TestGwanLibrary.pc in /usr/lib64/pkgconfig and the content looks like this.

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

I have tried placing TestGwanLibrary.pc in /usr/lib/pkgconfig and /usr/share/pkgconfig, both did not work, so I guess gwan binary is searching for packages only in /usr/lib64/pkgconfig.

In TestGwanLibrary.pc, Libs is pointing to where my custom .dll is stored, which is ../gwan/libraries/cs/dll/. This location cannot be changed as I believe there is some setting in gwan that searches this particular directory.

Second issue : Assembly 'netstandard' is not referenced.

/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

This issue is due to mono not supporting .NET Standard 2.0 and my library was built using this framework. To solve this, i built another library that targets .NET Framework 4.6.1.

So for those following C# section in G-WAN's FAQ, you will need to create a package file (.pc) for your library in directory, /usr/lib64/pkgconfig, as mentioned above.