Jason

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

server static void Job1(Args _args)
{
      CLRObject rdm;
      CLRObject num;
      int value;
      rdm = new CLRObject(\'System.Random\');
      num = rdm.Next();
        value = CLRInterop::getAnyTypeForObject(num);
      box::info(int2str(value));

static void Job1(Args _args)
{
    DLL dll ;
    DLLFunction interFaceLibrary;
    ;

    dll = new DLL(\'Net_DLL_Ax.dll\');
    interFaceLibrary  = new DLLFunction(dll,\'FirstClass.GetInformation\');

    interFaceLibrary.returns(ExtTypes::String);
   info(interFaceLibrary.call());

}

DLL文件C#代码:

using System;

namespace Net_DLL_Ax
{
    public class FirstClass
    {
        public FirstClass()
        {
        }

        public static string GetInformation()
        {
            return "HelloWorld";
        }
    }
}

 

 

总结了一下AX中调用NET中的DLL时要注意的一些方面(服务器端的部署):

1.在服务器上注册DLL程序集文件到GAC(全局程序集缓存)中,可以使用.Net的工具gacutil -i assemblyname.dll。

2.在ax中添加对NET的DLL文件的引用。

3.在代码中调用DLL之前要开启权限:

    Set                                     _assertSet;
    InteropPermission                       _ipCLR;    ;

    _assertSet = new Set(Types::Class);
    _ipCLR = new InteropPermission(InteropKind::ClrInterop);

    _assertSet.add(_ipCLR);

    CodeAccessPermission::assertMultiple(_assertSet);

部署好了以后就可以直接在客户端直接运行服务器端调用NET中DLL的项目了。

最郁闷的是按照步骤也不成功:( ,经验告诉我们“重启AX”!!!

posted on 2008-07-02 09:03  Jsang  阅读(699)  评论(2编辑  收藏  举报