AX中调用.Net的Dll时需要注意的几点。

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”!!!

转载于:https://www.cnblogs.com/muskteer/archive/2008/07/02/1233704.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值