如何使用GWAN C#servlet引用Mono C#程序集

时间:2014-02-03 12:05:45

标签: dll mono g-wan

我试图在gwan csp文件夹中包含一个c#servlet CompanyListService.cs并收到编译错误'找不到类型或命名空间名称`PropertyManagement'。您是否缺少using指令或程序集引用?'

PropertyManagement.sql.dll位于同一文件夹中。还尝试在GAC中安装它,没有运气。

如果使用'mcs CompanyListService.cs -r:PropertyManagement.Sql.dll',它会解析程序集

现有的Hello.cs和Loan.cs工作正常。任何帮助将不胜感激?

由于 拉姆

// C servlet example for the G-WAN Web Application Server 
// http://gwan.ch/
// hello.cs: G-WAN supports .NET C# servlets

using System;
using System.Collections.Generic;
//using PropertyManagement.Sql;
//using System.Runtime.Serialization.Json;
using System.Text;

public class CompanyListService
{
   public static int Main(string[] args)
   {
    PropertyManagement.Sql.CompanyRepository Repository = new PropertyManagement.Sql.CompanyRepository();
    List<PropertyManagement.Sql.Company> CompanyList = Repository.GetCompanyList();

    //string json = JsonSerializer<List<Company>>(CompanyList);

        Gwan.xbufCat(Gwan.getReply(args[0]), "test");
        return 200; // HTTP status (200:'OK')
   }
}

2 个答案:

答案 0 :(得分:0)

官方文档没有提及它,但loading dynamically your assemblies不仅可行,而且比traditional ways to do it提供更多灵活性。

毕竟,那是共享库的用途。感谢C#没有错过这一点。

此外,G-WAN在/usr/lib/mono路径下查找Mono库,并在/gwan/.../libraries/cs目录中查找用户定义的程序集(如G-WAN API)。

答案 1 :(得分:0)

根据另一个G-WAN + C#用户(Igor)的请求,G-WAN v4.12.21中添加了以下功能:

  • 创建$ MONO_PATH以包含目录 /.../ [金桂冠] /库/ CS / DLL

  • *。位于[gwan] / libraries / cs / dll下的dll文件 与-pkg:lib1,lib2 ...

  • 一起添加
  • 该行指定的任何库:

    // pragma link libname [,libname,...]

    ...在* .cs源代码文件中添加“-pkg:”开关。

希望它有所帮助。